Environment configuration when reproducing code

foreword

If you want to reproduce the code, installing the environment is the first step. The following records the problems and solutions I encountered during the installation, so that I can review them later. Please correct me if there are any mistakes.


Install pytorch and cuda

These two versions must correspond, you can view the configuration on this website https://pytorch.org/get-started/previous-versions/
For installing torchvision, you can install pytorch and cuda first and then use the following code to install:

conda install torchvision -c pytorch

Anaconda will automatically select the corresponding torchvision according to the version of pytorch, which is very convenient.


Problems with scikit-learn

If you install scikit-learn directly, regardless of the version, click to install, and you will feel refreshed for a while, and then the exception will be waiting for you.

'ModuleNotFoundError: No module named ‘sklearn.utils.linear_assignment_’

This is because of the version of scikit-learn. In the new version, linear_assignment is deprecated, and scipy.optimize.linear_sum_assignment is officially replaced by sklearn.utils.linear_assignment_.

Solution: The official deprecation of linear_assignment in version 0.23, I directly choose to lower the version and download the lower version of scikit-learn.

Replace scikit-learn version with pycharm's python interpreter interface.
insert image description here
Double-click the scikit-learn project bar to enter the following interface, select the version to be installed, and click Install Package.
insert image description here


Verify that the installation was successful

Enter the anaconda console, first activate your own virtual environment (activate+environment name), enter python, and then enter import torch, if there is no error, it means that pytorch has been installed successfully, then enter torch.cuda.is_available(), if it is True means that GPU training can be used, and if it is False, it means that only CPU can be used to check whether the installation of cuda and pytorch is successful.


'RuntimeError: CuDNN error: CUDNN_STATUS_SUCCESS' appears when running the code

Generally, it may be a problem of cuda and CuDNN version. The minimum cuda version that can be used by the graphics card should match the number of your cuda. ​​Use 'nvidia-smi' to view the highest version of CUDA currently supported (note: use 'nvcc -V' to see The cuda version that your current system uses by default).
Here's the nvcc -V command:
This is the nvcc -V command
Here's the nvidia-smi command:
insert image description here

ps: The cuda 9.0 I installed on the 3080 before was extremely slow when reading data, but after switching to the 2080, the reading speed is normal. So pay attention to the minimum cuda version your graphics card can support.

Guess you like

Origin blog.csdn.net/OnePiece_zym/article/details/130430334