I bought a new laptop and installed VS Code and Tensorflow on Windows. The TF Python script needs a conda virtual environment that can access Nvidia GPU card. I got the virtual environment working fine. I also got the TF Python scripts working in VS Code. However, when I use the same scripts in Jupyter notebook in VS Code, it cannot find the GPU. Both run the same virtual environment. The first screenshot shows it works in .py in VS Code:
Strangely, the same scripts in Jupyter notebook form cannot find the GPU. Please help.
2
Answers
It looks like a bug in VS Code. I was about to give up running TF on Windows with VS Code, and so installed Docker desktop app. Then it started to work. In other words, after I installed Docker desktop on the Windows, the VS Code and Jupyter notebook are able to use GPU.
Thanks everyone who helped.
One of these should either fix it or send you in the right direction.
Set the
CUDA_VISIBLE_DEVICES
environment variableManually set the GPU device with…
Make sure the Jupyter Notebook is using the same kernel as the command-line with
!which python
or!where python
or!conda env list
If it’s what you said in your question, you’re probably okay.Look at which version of TensorFlow you’ve got installed. If it’s pre-2.1, you’ll need
tensorflow-gpu
and nottensorflow
. Again, you’re probably okay here, too.Many problems are fixed by manually restarting the Jupyter kernel.