OLD: Pytorch Setup

Details on setting up Pytorch Setup

Just pip install fastAI

Computer Setup

  1. Uninstall
    • Onedrive
  2. Download and Install:
    • Matlab
    • Git
    • vscode
    • docker
    • anaconda
    • nvidia:
      • cuda toolkit

Program Setup

  • nbdev - see nbdev page

  • quarto - see quarto page

  • jupyter lab - see nbdev page

  • Optional installs

    • vim
    conda install -c conda-forge vim
    • grep
    conda install -c conda-forge grep

Prerequisites for pytorch

  1. Install Anaconda
  2. Install CUDA, if your machine has a CUDA-enabled GPU.
  3. If you want to build on Windows, Visual Studio with MSVC toolset, and NVTX are also needed. The exact requirements of those dependencies could be found out here.
  4. Follow the steps described here: https://github.com/pytorch/pytorch#from-source

For installing pytorch

mamba install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
Code
import torch
x = torch.rand(5,3)
print(x)
tensor([[0.9269, 0.1003, 0.0353],
        [0.4144, 0.8482, 0.3824],
        [0.1120, 0.7599, 0.8723],
        [0.0077, 0.7378, 0.8241],
        [0.3825, 0.3843, 0.2078]])
torch.cuda.is_available()
True
torch.cuda.device_count()
2
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device
device(type='cuda')
!nvcc --version
/bin/bash: line 1: nvcc: command not found
!nvidia-smi
Thu Jul 27 01:53:39 2023       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.61.03    Driver Version: 522.06       CUDA Version: 11.8     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0  On |                  N/A |
| N/A   42C    P8     4W /  N/A |    150MiB /  6144MiB |      2%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A        23      G   /Xwayland                       N/A      |
+-----------------------------------------------------------------------------+
!which python
/home/ben/mambaforge/envs/fast/bin/python
import sys
print(sys.executable)
print(sys.version)
/home/ben/mambaforge/envs/fast/bin/python3.11
3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0]
Back to top