PyTorch Setup

1.
Installation

Install the dependencies via conda. Nvidia drivers and libraries are loaded by setting the NEXTJOURNAL_MOUNT_CUDA environment variable.

conda install -c defaults -c intel \
  mkl mkl-include mkl-dnn \
  pyyaml cmake cffi typing pillow cython
conda install -c pytorch cuda92 magma-cuda92

conda clean -tipsy

ldconfig

Install torch and torchvision via pip. This ensures conda doesn't force redundant installs of cudatoolkit and cudnn.

pip install torch torchvision

2.
Testing

import torch

print(torch.cuda.current_device())
print(torch.cuda.device(0))
print(torch.cuda.device_count())
print(torch.cuda.get_device_name(0))
print(torch.cuda.is_available())
print(torch.rand(100,100).cuda())
© 2018 Nextjournal GmbH