I know that for jupyter notebooks and jupyter lab, there are available code formatter extensions such as nb_blackor blackcellmagic. However when I installed them, it doesn't seem to work on google colab.
Do you know if there are any native option in colab or an extension that formats code (pep8 compliant)?
I don't think there's an extension directly in Colab.
What you could do, though, is to download your notebook, run
pip install -U nbqa
nbqa black notebook.ipynb
and then reupload your (now formatted) notebook to Colab
disclaimer: I'm the author of nbQA
UPDATE: as of version 21.8b0, black runs directly on notebooks, no third-party tool required
I have tried everything, none of the JupyterLab/Notebook backend hack methods seem to work as of February 2022. However, until later here is a relatively simple workaround:
[Run only once, at startup]
Connect to your drive
from google.colab import drive
drive.mount("/content/drive")
Install black for jupyter
!pip install black[jupyter]
Restart kernel
[Then]
Place your .ipynb file somewhere on your drive
Anytime you want format your code run:
!black /content/drive/MyDrive/YOUR_PATH/YOUR_NOTEBOOK.ipynb
Don't save your notebook, hit F5 to refresh the page
Voila!
Now save!
Related
My problem is the following: I want to run a Jupyter notebook on my remote desktop and access it via my laptop elsewhere. I have accomplished this, but I can't use my GPU for tensorflow because the GPU-supported version is only installed in my custom, non-base environment. Even though all of my installed jupyter kernels are available, it seems things don't work right unless I run 'jupyter notebook' from within the correct activated conda environment (says "no GPU" even though I select as the kernel the one where tensorflow-gpu is installed).
Is there a simple way of running jupyter notebook from within that environment by a batch script? I also need it to run the notebook on a secondary drive.
I could of course just start up the server while at home and then access it using the token, but that's a little clumsy.
I've found a solution. On windows, in %AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3, there are shortcuts for various Anaconda-related programs, including Jupyter notebook for each environment.
The shortcut for Jupyter notebook for my given env is
`E:\Software\Anaconda3\python.exe E:\Software\Anaconda3\cwp.py E:\Software\Anaconda3\envs\tf E:\Software\Anaconda3\envs\tf\python.exe E:\Software\Anaconda3\envs\tf\Scripts\jupyter-notebook-script.py "%USERPROFILE%".
I modified this to end in '"E:" --no-browser' instead of the userprofile bit and made that into a script. Now when I SSH into the computer and run this script, the notebook is within the correct environment and I have access to my GPU, all on the correct drive, E.
I trying to use jovian platform and google colab to run jupyter notebook. When I am trying to upload the notebook to my jovian account, I see this error.
Colab commit failed: (HTTP 400) Unauthorized access to tahmid1989/01-pytorch-basics
I am giving correct API key when it is prompted.
I am using same google account for my google colab and jovian.
Still it is not working.
Here is what I am trying.
!pip install jovian --upgrade --quiet
import jovian
jovian.commit(project='01-pytorch-basics')
Are you opening Colab from Jovian? It would be better to open the notebook on Colab via Jovian.
enter image description here
I can only commit my notebook from Colab to Jovian when I open it via Jovian.
Alternatively, you can try to run the Jupyter locally or run on Binder, then will be able to commit to Jovian..
logout and login once from jovian.ai
restart kernel on Colab
run jovian.commit as usual
I understand why it’s happening, will fix. But for now logout/login should work for you.
I am working with tensorflow 2.0 beta, and while i managed to get my GPU working on anaconda through a few youtube tutorials I am unable to get my gpu running in google colab. I know google has the option to enable a gpu from one of their servers but My GTX 1070 is much faster, and i need to run off colab and not just Jupyter exclusively.
So I read the documentation like a good boy and the only thing i think i could have done wrong is my path settings I have screenshots bellow.
I followed several different youtube tutorials faithfully until the final one here gave me a way to install it to jupyter. Which is great, but I also need it to run on google colab as well.
I've been trying this since Friday and it's now tuesday and I'm losing my mind over this. Help me stackoverflow, you're my only hope.
https://imgur.com/a/8WibGWT
If you can get it running on your own Jupyter server then you can point colab to that local server.
Full instructions here: https://research.google.com/colaboratory/local-runtimes.html but edited highlights are:
install jupyter_http_over_ws:
pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws
start your local server allowing colab domain:
jupyter notebook \
--NotebookApp.allow_origin='https://colab.research.google.com' \
--port=8888 \
--NotebookApp.port_retries=0
Click 'connect to local runtime' in colab
I'm Attempting to run "First steps with Tensorflow" locally, outside of colab. Not really familiar with colab so I don't know how to access the "dataframes" such as "california_housing_dataframe", etc. Evidently colab "knows" how to access the dataframes in the example but I am attempting to run the exercise natively on my local system.
Thank You
I think you should have Pandas library locally installed. Then, I think it would run natively.
Do I absolutely need to use jupyter notebook to run TensorFlow in Windows ?
I tried the detect object example with the jupyter notebook, it works but I'm not really comfortable, Im used to notepad++ and running python directly on my windows without virtual environment.
I tried to copy past all the codes but I run into many hugs.
No, it is not compulsory to use Jupyter notebook to run Tensorflow on Windows. I personally use PyCharm as my IDE and Anaconda for dependency management (this is completely optional).
I would recommend you to use a proper IDE instead of notepad++ because it's much easier to do debugging using an IDE. You'll also be cloning a lot from Git when you start developing your own model, and usually the open source models out there has a lot of classes and methods in it (take Google's Inception net for example).
Another alternative would be maybe you can start posting about the bugs you are facing, then we can all start helping you.