Python 3.11 安装Pytorch开发环境
# 环境 Ubuntu 18.04, 选择环境 CUDA 11.6, 之前已安装驱动和CUDA,CUDNN环境
# 安装 Python3.11
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11
# 配置默认的python版本
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
# 安装pip
sudo apt install python3.11-venv
python3.11 -m ensurepip
安装Pytorch
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu116
实际上,我是
wget https://download.pytorch.org/whl/cu116/torch-1.13.0%2Bcu116-cp311-cp311-linux_x86_64.whl
python -m pip install torch-1.13.0+cu116-cp311-cp311-linux_x86_64.whl
# 安装 torchvision
打开 https://download.pytorch.org/whl/torchvision/
下载 torchvision-0.14.0+cu116-cp310-cp310-linux_x86_64.whl
当时没有针对3.11版本的,于是下载了3.10的,然后改名为:
torchvision-0.14.0+cu116-cp311-cp311-linux_x86_64.whl
再安装
python -m pip install torchvision-0.14.0+cu116-cp311-cp311-linux_x86_64.whl
# 安装timm
直接 python -m pip install timm 安装的是 0.6.11版本,会报错:
import timm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.local/lib/python3.11/site-packages/timm/init.py", line 2, in <module>
from .models import create_model, list_models, is_model, list_modules, model _entrypoint,
File "/home/ubuntu/.local/lib/python3.11/site-packages/timm/models/init.py ", line 28, in <module>
from .maxxvit import *
File "/home/ubuntu/.local/lib/python3.11/site-packages/timm/models/maxxvit.py" , line 216, in <module>
@dataclass
^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 1221, in dataclass
return wrap(cls)
^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 1211, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 959, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 816, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'timm.models.maxxvit.MaxxVitConvCfg'> for fie
需要指定一个低一点的版本
python -m pip install timm==0.6.7
版权归原作者 makao007 所有, 如有侵权,请联系我们删除。