ubuntu大服务器 pytorch环境配置

ubuntu大服务器

star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~/Yolov/yolov5-master$ conda create -n wind_202103 python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.8.3
  latest version: 4.9.2

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /home/star/anaconda3/envs/wind_202103

  added / updated specs:
    - python=3.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _libgcc_mutex-0.1          |      conda_forge           3 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    _openmp_mutex-4.5          |            1_gnu          22 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ca-certificates-2020.12.5  |       ha878542_0         137 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    certifi-2020.12.5          |   py37h89c1867_1         143 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ld_impl_linux-64-2.35.1    |       hea4e1c9_1         617 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libffi-3.3                 |       h58526e2_2          51 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libgcc-ng-9.3.0            |      h5dbcf3e_17         7.8 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libgomp-9.3.0              |      h5dbcf3e_17         378 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libstdcxx-ng-9.3.0         |      h2ae2ef3_17         4.0 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ncurses-6.2                |       h58526e2_4         985 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    openssl-1.1.1i             |       h7f98852_0         2.1 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    pip-20.3.3                 |     pyhd8ed1ab_0         1.1 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    python-3.7.9               |hffdb5ce_0_cpython        57.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    python_abi-3.7             |          1_cp37m           4 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    readline-8.0               |       he28a2e2_2         281 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    setuptools-49.6.0          |   py37h89c1867_3         947 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    sqlite-3.34.0              |       h74cdb3f_0         1.4 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    tk-8.6.10                  |       h21135ba_1         3.2 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    wheel-0.36.2               |     pyhd3deb0d_0          31 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    xz-5.2.5                   |       h516909a_1         343 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    zlib-1.2.11                |    h516909a_1010         106 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ------------------------------------------------------------
                                           Total:        81.0 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      anaconda/cloud/conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      anaconda/cloud/conda-forge/linux-64::_openmp_mutex-4.5-1_gnu
  ca-certificates    anaconda/cloud/conda-forge/linux-64::ca-certificates-2020.12.5-ha878542_0
  certifi            anaconda/cloud/conda-forge/linux-64::certifi-2020.12.5-py37h89c1867_1
  ld_impl_linux-64   anaconda/cloud/conda-forge/linux-64::ld_impl_linux-64-2.35.1-hea4e1c9_1
  libffi             anaconda/cloud/conda-forge/linux-64::libffi-3.3-h58526e2_2
  libgcc-ng          anaconda/cloud/conda-forge/linux-64::libgcc-ng-9.3.0-h5dbcf3e_17
  libgomp            anaconda/cloud/conda-forge/linux-64::libgomp-9.3.0-h5dbcf3e_17
  libstdcxx-ng       anaconda/cloud/conda-forge/linux-64::libstdcxx-ng-9.3.0-h2ae2ef3_17
  ncurses            anaconda/cloud/conda-forge/linux-64::ncurses-6.2-h58526e2_4
  openssl            anaconda/cloud/conda-forge/linux-64::openssl-1.1.1i-h7f98852_0
  pip                anaconda/cloud/conda-forge/noarch::pip-20.3.3-pyhd8ed1ab_0
  python             anaconda/cloud/conda-forge/linux-64::python-3.7.9-hffdb5ce_0_cpython
  python_abi         anaconda/cloud/conda-forge/linux-64::python_abi-3.7-1_cp37m
  readline           anaconda/cloud/conda-forge/linux-64::readline-8.0-he28a2e2_2
  setuptools         anaconda/cloud/conda-forge/linux-64::setuptools-49.6.0-py37h89c1867_3
  sqlite             anaconda/cloud/conda-forge/linux-64::sqlite-3.34.0-h74cdb3f_0
  tk                 anaconda/cloud/conda-forge/linux-64::tk-8.6.10-h21135ba_1
  wheel              anaconda/cloud/conda-forge/noarch::wheel-0.36.2-pyhd3deb0d_0
  xz                 anaconda/cloud/conda-forge/linux-64::xz-5.2.5-h516909a_1
  zlib               anaconda/cloud/conda-forge/linux-64::zlib-1.2.11-h516909a_1010


Proceed ([y]/n)? Y


Downloading and Extracting Packages
libgomp-9.3.0        | 378 KB    | #################################################################### | 100% 
python-3.7.9         | 57.3 MB   | #################################################################### | 100% 
xz-5.2.5             | 343 KB    | #################################################################### | 100% 
_openmp_mutex-4.5    | 22 KB     | #################################################################### | 100% 
setuptools-49.6.0    | 947 KB    | #################################################################### | 100% 
libstdcxx-ng-9.3.0   | 4.0 MB    | #################################################################### | 100% 
sqlite-3.34.0        | 1.4 MB    | #################################################################### | 100% 
_libgcc_mutex-0.1    | 3 KB      | #################################################################### | 100% 
zlib-1.2.11          | 106 KB    | #################################################################### | 100% 
tk-8.6.10            | 3.2 MB    | #################################################################### | 100% 
ca-certificates-2020 | 137 KB    | #################################################################### | 100% 
ncurses-6.2          | 985 KB    | #################################################################### | 100% 
python_abi-3.7       | 4 KB      | #################################################################### | 100% 
pip-20.3.3           | 1.1 MB    | #################################################################### | 100% 
ld_impl_linux-64-2.3 | 617 KB    | #################################################################### | 100% 
certifi-2020.12.5    | 143 KB    | #################################################################### | 100% 
libgcc-ng-9.3.0      | 7.8 MB    | #################################################################### | 100% 
readline-8.0         | 281 KB    | #################################################################### | 100% 
wheel-0.36.2         | 31 KB     | #################################################################### | 100% 
openssl-1.1.1i       | 2.1 MB    | #################################################################### | 100% 
libffi-3.3           | 51 KB     | #################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate wind_202103
#
# To deactivate an active environment, use
#
#     $ conda deactivate

star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~/Yolov/yolov5-master$ 
star@xmatrix:~$ nvidia-smi
Thu Dec 26 17:19:43 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.67       Driver Version: 418.67       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla P4            Off  | 00000000:02:00.0 Off |                    0 |
| N/A   76C    P0    43W /  75W |   7483MiB /  7611MiB |     48%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     10454      C   python                                      7473MiB |
+-----------------------------------------------------------------------------+
star@xmatrix:~$ 
star@xmatrix:~$ 

下载并安装torch 1.7

(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ pip install torch-1.7.1+cu101-cp37-cp37m-linux_x86_64.whl
Processing ./torch-1.7.1+cu101-cp37-cp37m-linux_x86_64.whl
Collecting numpy
  Downloading numpy-1.19.5-cp37-cp37m-manylinux2010_x86_64.whl (14.8 MB)
     |████████████████████████████████| 14.8 MB 12.2 MB/s 
Collecting typing-extensions
  Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Installing collected packages: typing-extensions, numpy, torch
Successfully installed numpy-1.19.5 torch-1.7.1+cu101 typing-extensions-3.7.4.3
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ pip install torchvision==0.8.2
Collecting torchvision==0.8.2
  Downloading torchvision-0.8.2-cp37-cp37m-manylinux1_x86_64.whl (12.8 MB)
     |████████████████████████████████| 12.8 MB 12.4 MB/s 
Requirement already satisfied: torch==1.7.1 in /home/star/anaconda3/envs/wind_202103/lib/python3.7/site-packages (from torchvision==0.8.2) (1.7.1+cu101)
Requirement already satisfied: numpy in /home/star/anaconda3/envs/wind_202103/lib/python3.7/site-packages (from torchvision==0.8.2) (1.19.5)
Requirement already satisfied: typing-extensions in /home/star/anaconda3/envs/wind_202103/lib/python3.7/site-packages (from torch==1.7.1->torchvision==0.8.2) (3.7.4.3)
Collecting pillow>=4.1.1
  Downloading Pillow-8.1.0-cp37-cp37m-manylinux1_x86_64.whl (2.2 MB)
     |████████████████████████████████| 2.2 MB 12.9 MB/s 
Installing collected packages: pillow, torchvision
Successfully installed pillow-8.1.0 torchvision-0.8.2
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ pip install torchaudio===0.7.2
Collecting torchaudio===0.7.2
  Downloading torchaudio-0.7.2-cp37-cp37m-manylinux1_x86_64.whl (7.6 MB)
     |████████████████████████████████| 7.6 MB 1.3 MB/s 
Requirement already satisfied: torch==1.7.1 in /home/star/anaconda3/envs/wind_202103/lib/python3.7/site-packages (from torchaudio===0.7.2) (1.7.1+cu101)
Requirement already satisfied: typing-extensions in /home/star/anaconda3/envs/wind_202103/lib/python3.7/site-packages (from torch==1.7.1->torchaudio===0.7.2) (3.7.4.3)
Requirement already satisfied: numpy in /home/star/anaconda3/envs/wind_202103/lib/python3.7/site-packages (from torch==1.7.1->torchaudio===0.7.2) (1.19.5)
Installing collected packages: torchaudio
Successfully installed torchaudio-0.7.2
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ python
Python 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 21:08:20) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> import torch
>>> 
>>> x=torch.Tensor([1.0])
>>> 
>>> xx=x.cuda()
>>> 
>>> 
>>> print(xx)
tensor([1.], device='cuda:0')
>>> 
>>> 
>>> exit();

(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
(wind_202103) star@xmatrix:~/PyTorch$ 
原文地址:https://www.cnblogs.com/herd/p/14269283.html