Machine Learning
Machine Learning
Kindly refer to the website https://developer.nvidia.com/cuda-toolkit-archive/ for the installation of CUDA Toolkit and NVIDIA driver. If the NVIDIA driver is not installed at present, please select "deb" (local) as the installation type and meticulously follow the installation instructions available on the website or the provided following code below. However, in case you have already installed the NVIDIA driver, you will be required to opt for "runfile" (local) as the installer type.
$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
$ sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
$ wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-ubuntu2004-11-8-local_11.8.0-520.61.05-1_amd64.deb
$ sudo dpkg -i cuda-repo-ubuntu2004-11-8-local_11.8.0-520.61.05-1_amd64.deb
$ sudo cp /var/cuda-repo-ubuntu2004-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
$ sudo apt-get update
$ sudo apt-get -y install cuda
System reboot and verify the successful completion of the installation process.
$ nvidia-smi
Download cuDNN from https://developer.nvidia.com/cudnn/. Keep in mind that a login is necessary, and it is crucial to select the cuDNN version that is compatible with the installed CUDA Toolkit version.
Unzip the file and copy the required files.
$ tar -xzvf cudnn-linux-x86_64-8.9.2.26_cuda11-archive.tar.xz
$ sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
$ sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
Add the environment variables into the bashrc file, verify the proper installation of cuDNN. If everything is functioning correctly, executing the last line of the code below will result in the printed text: "Result = PASS."
$ vi ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.8/lib64/
$ source ~/.bashrc
$ /usr/local/cuda-11.8/extras/demo_suite/deviceQuery
Download the Anaconda3 bash file from https://www.anaconda.com/download/ and installation. Then, add the environment variables into bashrc file.
$ bash Anaconda3-2023.03-1-Linux-x86_64.sh
$ vi ~/.bashrc
export PATH=/your/directory/anaconda3/bin:/your/directory/anaconda3/condabin:$PATH
$ source ~/.bashrc
Discover a installation command of PyTorch, considering the installed version of the CUDA Toolkit, from https://pytorch.org/get-started/locally/.
$ conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
or
$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118