在Conda虚拟环境中安装cudatoolkit时出现了上图所示的错误。
conda install cudatoolkit==11.2.2
环境: Windows10,Anaconda 4.10.3 ,python 3.8.5, tensorflow-gpu=2.6.0
完整错误如下:
ERROR conda.core.link:_execute(701): An error occurred while installing package 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge::cudatoolkit-11.2.2-h933977f_9'.
Rolling back transaction: done
LinkError: post-link script failed for package https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge::cudatoolkit-11.2.2-h933977f_9
location of failed script: D:\Program\Anaconda\envs\tensorflow\Scripts\.cudatoolkit-post-link.bat
==> script messages <==
"By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement(EULA): https://docs.nvidia.com/cuda/eula/index.html"
==> script output <==
stdout:
stderr: 'chcp' is not recognized as an internal or external command,
operable program or batch file.
'chcp' is not recognized as an internal or external command,
operable program or batch file.
'chcp' is not recognized as an internal or external command,
operable program or batch file.
return code: 1
该错误应当是cudatoolkit安装程序.cudatoolkit-post-link.bat运行时无法调用cmd命令'chcp'导致。将"C:\Windows\System32"添加到环境变量Path中即可。