Categories
Deep Learning

Install Tensorflow GPU in Jupyter Notebook Windows

Note:

Please go to the latest update article here https://www.yodiw.com/fix-install-tensorflow-2-with-gpu-simple-version-2023/

Author

Jupyter Notebook from Anaconda is not coming with Tensorflow by default. If you are using Windows and want to leverage your GPU (mine is RTX 3060Ti), you can install Tensorflow GPU integrated with your Jupyter.

In this steps, no Python installation required, since we will using Python from Anaconda (~ version 3.9). This is also to reduce complexity of using different virtual environment in Conda.

Yes, in this step, the TensorFlow will automatically load into your default Jupyter root base environment and will not require installing a new one.

TLDR;

  • Install the latest Nvidia GPU drivers card + Anaconda
  • the Microsoft Visual C++ (MSVC) compiler 2022
  • the CUDA Toolkit 11.8
  • Install conda tookit and pip
  • Install tensorflow-gpu

I assume you already have Nvidia driver and Anaconda installed, next follow the guidelines below:

Caveat from me

1. I have several errors when doing the installation. So I decided to do do fresh reset my Windows (I using windows 11) this step.

2. Instead of using Nvidia Geforce Experience, I uninstall the GPU drivers (back to Microsoft Basic) and use NVCleanstall to download my RTX 3060 drivers without others bloatware https://www.techpowerup.com/download/techpowerup-nvcleanstall/

3. I use the latest Anaconda
Go to https://www.anaconda.com/products/distribution

Step 1

Install Microsoft Visual Studio 2022, which will required by CUDA for integration. You can download the community version. In the installation step, please check for C/C++ development installation

https://learn.microsoft.com/en-us/visualstudio/releases/2022/compatibility

This will take sometimes to complete and depend to your internet connection

Step 2

Install CUDA 12 https://developer.nvidia.com/cuda-toolkit (3.5GB filesize)

Step 3

Download the CUDA toolkit via Conda (launch terminal in Windows) and execute this command. FYI, we are using pip from Conda Python, not from separate Python installation (If you have it, please uninstall)

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0 pip

Then you are ready to install Tensorflow GPU

pip install "tensorflow<2.11"

To test whether its active or not, you can execute this

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Finalization

Open your Jupyter ( no need to restart the Anaconda Navigator, because this installation will come with auto-reload), you can import tensorflow and test if the GPU is active or not

Hope this help you! Happy learning Deep Learning!

Leave a Reply

Your email address will not be published. Required fields are marked *