切换国内安装镜像源:
pip install [需要安装的库] -i https://pypi.tuna.tsinghua.edu.cn/simple
清华: https://pypi.tuna.tsinghua.edu.cn/simple
阿里: http://mirrors.aliyun.com/pypi/simple/
豆瓣: http://pypi.douban.com/simple/
pytorch安装与配置
pytorch官网:https://pytorch.org/
一、运行train.py报错:
TypeError: type torch.cuda.LongTensor not available. Torch not compiled with CUDA enabled.
原因:镜像源下载的一般为CPU版本,也是这导致前面所说一直返回false。
解决:
使用conda卸载pytorch
conda uninstall pytorch
conda uninstall libtorch
cmd查看cuda版本
nvcc --version
cuda版本是10.2
离线下载pytorch,并拷贝到安装的环境中
网址:https://download.pytorch.org/whl/torch_stable.html
下载地址:
https://download.pytorch.org/whl/cu102/torch-1.8.1%2Bcu102-cp39-cp39-win_amd64.whl
安装
pip install numpy-1.24.2-cp39-cp39-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install torch-1.8.1+cu102-cp39-cp39-win_amd64.whl
Use --force-reinstall to force an installation of the wheel.
检查
import torch
print(torch.__version__)
print(torch.cuda.is_available())
print(torch.cuda.device_count())
报错:
OSError: Can't load the configuration of '../pretrain/DNAbert_3mer'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure '../pretrain/DNAbert_3mer' is the correct path to a directory containing a config.json file
OSError:无法加载'../pretrain/DNAbert_3mer'的配置。如果您试图从https://huggingface.co/models加载它,确保你没有一个同名的本地目录。否则,请确保../pretrain/DNAbert_3mer是包含config.json文件的目录的正确路径。
服务器运行
报错:TypeError: type torch.cuda.LongTensor not available. Torch not compiled with CUDA enabled.
查看显卡版本
lspci | grep -i nvidia
没有输出
重新输入:
lspci | grep -i vga
返回:
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
没有nvidia显卡,只有一个普通显卡,即便安装cuda也没用,不能加速计算。
(参考:https://blog.csdn.net/feng_1_ying/article/details/107307015)
确认Linux版本是否支持CUDA
uname -m && cat /etc/*release
若有信息输出,说明linux支持