首页 > 解决方案 > tensorflow-gpu 安装在 ubuntu 18 上失败“InvalidArchiveError('存档错误 /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0.tar.bz2。”

问题描述

我正在尝试在启用 GPU 的 ubuntu 18 机器上安装 tensorflow GPU。我安装了 Nvidia 驱动程序并为 python 和 tensorflow 使用 anaconda 环境。当我尝试安装 tansorflow-gpu 时,

conda install -c anaconda tensorflow-gpu

安装失败并出现以下错误

InvalidArchiveError('Error with archive /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0.tar.bz2.  You probably need to delete and re-download or re-create this file.  Message from libarchive was:\n\nCou
ld not unlink')

较大的堆栈跟踪如下

WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/recipe/build.py.  Please remove this file manually (you
 may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/recipe/.gitignore.  Please remove this file manually (y
ou may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/recipe/LICENSE.  Please remove this file manually (you 
may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/recipe/meta.yaml.template.  Please remove this file man
ually (you may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/recipe/run_test.py.  Please remove this file manually (
you may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/git.  Please remove this file manually (you may need to
 reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/hash_input.json.  Please remove this file manually (you
 may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/index.json.  Please remove this file manually (you may 
need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/about.json.  Please remove this file manually (you may 
need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/paths.json.  Please remove this file manually (you may 
need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/files.  Please remove this file manually (you may need 
to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0/info/repodata_record.json.  Please remove this file manually
 (you may need to reboot to free file handles)
cudatoolkit-10.1.243 | 513.2 MB  | ############################################################################################################################################################## | 100% 

InvalidArchiveError('Error with archive /anaconda/pkgs/cudatoolkit-10.1.243-h6bb024c_0.tar.bz2.  You probably need to delete and re-download or re-create this file.  Message from libarchive was:\n\nCou
ld not unlink')

(base) azure@sibi-ds-gpu-vm:~$ cudatoolkit-10.1.243 | 513.2 MB  | #######################################################################################################################################
####################### | 100% 

知道这意味着什么以及如何解决这个问题吗?

标签: pythontensorflowanacondacondaubuntu-18.04

解决方案


使用 Anaconda 安装 TensorFlow-GPU

$ conda create -n tf_gpu python=3.6     # create new env, with name "tf"
$ pip install -U pip             # ensure new version available
$ conda activate tf_gpu 
$ pip install -U tensorflow
$ conda install -c anaconda cudatoolkit=10.1.243 cudnn=7.6.5   # install compatible CUDAtoolkit for your driver
$ pip install ipython

推荐阅读