Setting Up Deep Learning Environment (Pytorch)

1 Configuration Issues

(1). For computers equipped with a GPU and a need for deep learning, set up a usable and clean deep learning environment.

(2). Configure with Anaconda3 + CUDA10.0 + CuDNN + Pytorch1.2 + Pycharm.

(3). Resolve the issue of not being able to use the torchvision library in Pytorch.

2 Setup Process

(1). Install Anaconda. Download according to your computer’s requirements, extract the installation package, and follow the instructions step by step to complete the installation. Verify if the installation is successful and create a virtual environment for future configuration.

# Create virtual environment: (enter in cmd terminal) conda create -n Pytorch_GPU python=3.7&

Setting Up Deep Learning Environment (Pytorch)

(2). Install CUDA10.0 and cuDNN (must correspond to your Pytorch==1.2.0 version).

  1. . Find the suitable version on the official website for download and installation.

  2. . Find the installation location and extract cuDNN.

    Setting Up Deep Learning Environment (Pytorch)Setting Up Deep Learning Environment (Pytorch)(3). Install Pytorch.

    1. . Activate and enter the virtual environment prepared in Anaconda.

activate Pytorch_GPU

2). Download and install Pytorch. Open the Pytorch official website at: https://pytorch.org/.

You can also download the wheel (https://download.pytorch.org/whl/torch_stable.html).

Setting Up Deep Learning Environment (Pytorch)

Setting Up Deep Learning Environment (Pytorch)

(4) Connect Pycharm with Anaconda.

  1. . Set the relevant environment; there are many tutorials available online.Setting Up Deep Learning Environment (Pytorch)

  2. . Verify that Pytorch is configured successfully.

    Setting Up Deep Learning Environment (Pytorch)(5). Issue with torchvision.

    When importing torchvision, an error occurred, but it was found that the torchvision package is in the library.

    Found the solution online.

    Setting Up Deep Learning Environment (Pytorch)Locate the error path C:\Users\Public\Anaconda3\Lib\site-packages\PIL, open the __init__.py file, and replace the line from PIL import Image, ImageOps, ImageEnhance,PILLOW_VERSION with from PIL import Image, ImageOps, ImageEnhance, __version__.

3 Conclusion

1. Pay attention to the compatibility issues between various software versions.

2. The latest version of CUDA no longer requires configuring Cudnn for acceleration.

3. For the missing module issue when importing torchvision, changing the import module name in __init__.py file will resolve it.

Leave a Comment