使用CUDA的Tensorflow:ImportError(Tensorflow with CUDA: ImportError)
我已经像NVIDIA(Ubuntu 16.04 Desktop,GTX 970)本教程中所描述的那样逐步安装了TensorFlow:
http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html
每个步骤都完成没有错误,但如果我之后尝试在Python中导入TensorFlow,我总是得到这个错误消息:
>>> import tensorflow as tf Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module> from tensorflow.python import * File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 72, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 61, in <module> from tensorflow.python import pywrap_tensorflow File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module> _pywrap_tensorflow = swig_import_helper() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory Failed to load the native TensorFlow runtime. See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
我已经将CUDA-Toolkit安装到/ opt / cuda / toolkit(也是cuDNN)。 我已经尝试过符号链接:
sudo ln -s /opt/cuda-toolkit /usr/local/cuda sudo ln -s /opt/cuda-toolkit /usr/local/cuda-8.0
或这个:
sudo export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cuda-toolkit/lib64:/opt/cuda-toolkit/extras/CUPTI/lib64 sudo export CUDA_HOME=/opt/cuda-toolkit
但错误仍然存在。 任何人都可以给我一个暗示,为什么会出现这个错误? 非常感谢 :)
I've installed TensorFlow step by step like described in this tutorial from NVIDIA (Ubuntu 16.04 Desktop, GTX 970):
http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html
Every steps completes without errors, but if I try to import TensorFlow in Python afterwards I'm always gettin' this error message:
>>> import tensorflow as tf Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module> from tensorflow.python import * File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 72, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 61, in <module> from tensorflow.python import pywrap_tensorflow File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module> _pywrap_tensorflow = swig_import_helper() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory Failed to load the native TensorFlow runtime. See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
I've installed the CUDA-Toolkit to /opt/cuda/toolkit (also cuDNN). I already tried to symlink:
sudo ln -s /opt/cuda-toolkit /usr/local/cuda sudo ln -s /opt/cuda-toolkit /usr/local/cuda-8.0
Or this:
sudo export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cuda-toolkit/lib64:/opt/cuda-toolkit/extras/CUPTI/lib64 sudo export CUDA_HOME=/opt/cuda-toolkit
But the error remains. Can anybody give me a hint why this error occurs? Thanks a lot :)
原文:https://stackoverflow.com/questions/41746576
最满意答案
尝试这个:
我刚才写过它。
@echo off setlocal ENABLEDELAYEDEXPANSION set today=!date:/=-! set now=!time::=-! set millis=!now:*.=! set now=!now:.%millis%=! echo hello world > my-file-!today!_!now!.txt
Try this:
I had written it a while ago.
@echo off setlocal ENABLEDELAYEDEXPANSION set today=!date:/=-! set now=!time::=-! set millis=!now:*.=! set now=!now:.%millis%=! echo hello world > my-file-!today!_!now!.txt
相关问答
更多-
如何在Windows XP / 7上将文件打印到Python 3中?(How to print a file to paper in Python 3 on windows XP/7?)[2022-01-07]
一个简单的方法是让记事本打印文本文件: import subprocess subprocess.call(['notepad', '/p', filename]) A simple approach is to have Notepad print the text file: import subprocess subprocess.call(['notepad', '/p', filename]) -
NTFS中的最大文件名长度(Windows XP和Windows Vista)?(Maximum filename length in NTFS (Windows XP and Windows Vista)?)[2022-11-11]
文件名的单个组件(即沿着路径的每个子目录和最终文件名)限制为255个字符,总路径长度限制为大约32,000个字符。 但是,如果可能,您通常应尝试将路径长度限制在260个字符以下( MAX_PATH )。 有关详细信息,请参阅http://msdn.microsoft.com/en-us/library/aa365247.aspx 。 Individual components of a filename (i.e. each subdirectory along the path, and the fina ... -
请参阅Windows批处理文件(.bat)以MMDDYYYY格式获取当前日期 : @echo off For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b) echo %mydate%_%mytime% 如果您喜欢24小时/军事格式的时间,您可以用以下替换第二个FOR ...
-
尝试这个: 我刚才写过它。 @echo off setlocal ENABLEDELAYEDEXPANSION set today=!date:/=-! set now=!time::=-! set millis=!now:*.=! set now=!now:.%millis%=! echo hello world > my-file-!today!_!now!.txt Try this: I had written it a while ago. @echo off setlocal ENABLED ...
-
您可能会发现更容易做到这样的事情: md "\\SERVER\PATH\TO\FILE DIR" 2>NUL copy "\\SERVER\PATH\TO\ORIG FILE\FILE TEMP.XLSM" "\\SERVER\PATH\TO\FILE DIR\FILE FINAL.XLSM" 最初的'md'将尝试创建目录。 如果它已经存在,它将向STDERR输出一条错误消息。 2>NUL将其重定向到Windows的内置“空设备”,也就是说,它只是吞下错误消息。 假设您具有适当的权限,则可以确保此目录现在 ...
-
您可以在Shift+F和n之后创建一个带有W的〜/ .toprc。 然后按内存使用情况排序是默认的。 之后,您只需要top -b -n1 >top.txt 。 You could create a ~/.toprc with W in top after Shift+F and n. Then sorting by memory usage is default. After that, you only need top -b -n1 >top.txt.
-
如何在批处理脚本中将日期和时间插入到文件名中?(How to insert date and time to a filename in a batch script? [duplicate])[2022-06-10]
因为你显然没有使用PowerShell的问题,所以把前两行替换为: For /F %%A In ('Powershell -C "Get-Date -Format yyyyMMdd_HHmm"' ) Do Set "archive=bin-%%A.zip" 然后,您将完整的归档文件名称设置在变量%archive%以用于以下命令。 Because you obviously have no issue with powershell usage, replace those first two lines ... -
使用cscript将文本从slmgr输出到控制台。 cscript slmgr.vbs /xpr Use cscript to output text from slmgr to the console. cscript slmgr.vbs /xpr
-
测试一下: @echo off For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @( Set Day=%%A Set Month=%%B Set Year=%%C ) set "baseName=testing-%Year%%Month%%Day%-" set "n=0" :loop set /a n+=1 if exist "%baseName%%n%.txt" goto :loop type nul > "%base ...
-
for %%i in (*.txt) do rename %%i 20110822%%i 请注意,只有批处理文件才需要双百分号。 从交互式命令行中,仅使用一个百分号。 for %%i in (*.txt) do rename %%i 20110822%%i Note that the double-percent-signs are only needed in a batch file. From an interactive command line, use only one percent-si ...