Setting up Windows for using CUDA 12.0
Wondering how to use GPU in Windows with CUDA 12.0 driver installed for deep learning model. PyTorch has released one version to configure CUDa 12 computers to use GPUs. Following steps will get you done with setting up your python environment for using GPU for deep learning model building in PyTorch.
Installing Anaconda
Download Anaconda Python distribution: Visit https://www.anaconda.com/download to download the anaconda by choosing Download under Download button.
Install Anaconda just by clicking the downloaded package.
Create a Virtual Environment
Open the Terminal.
Create a virtual environment using Conda: conda create -n yourenvname python=x.x anaconda
Activate Virtual Environment
Open Terminal and activate the new environment: conda activate yourenvname
As you enter into new environment, lets install jupyter notebook inside it. pip install notebook
Being in the environment, install ipython kernel: python -m ipykernel install --user --name=yourenvironment
Install PyTorch for Enabling GPU
Just execute this command under
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch-nightly -c nvidia
This should install the PyTorch with support for accelerated computation on CUDA 12.x enabled NVIDIA RTX GPU.
Checking if it is Working
open notebook by writing: jupyter notebook being in the environment.
Write following codes in the Jupyter notebook cell.
import torch
import math
print(torch.cuda.is_available())
The outcome should True.