项目场景:
配置项目环境: https://github.com/JH-LEE-KR/l2p-pytorch
问题描述
服务器安装了CUDA11.6,于是通过以下命令在虚拟环境中安装了pytorch:
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge
然后在项目中运行如下指令:
python -m torch.distributed.launch --nproc_per_node=1 --use_env main.py cifar100_l2p --model vit_base_patch16_224 --batch-size 16 --data-path ./local_datasets --output_dir ./output
但是报如下错误:
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemmStridedBatched( handle, opa, opb, m, n, k, &alpha, a, lda, stridea, b, ldb, strideb, &beta, c, ldc, stridec, num_batches)`
原因分析:
参考了博文:https://blog.csdn.net/weixin_44162363/article/details/135079411
我发现在虚拟环境中的python终端执行如下命令后:
import torch
print(torch.__version__)
输出为:
1.12.1
这里其实有点问题,看下面解决方法
解决方案:
不通过上面提到的命令安装pytorch 1.12.1版本,而是通过pip命令来安装对应的pytorch版本:
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
通过这种方式安装后,同样执行上面打印pytorch版本命令后,输出为:
1.12.1+cu116
而且此时运行程序执行命令后,不再报错