解决Ubuntu18中的pycharm不能调用tensorflow-gpu的问题
问题描述:我通过控制台使用tensorflow-gpu没问题,但是通过pycharm使用却不可以,如下所示:
通过控制台:
answer@answer-desktop:/$python Python3.7.0(default,Jun282018,13:15:42) [GCC7.2.0]::Anaconda,Inc.onlinux Type"help","copyright","credits"or"license"formoreinformation. >>>importtensorflowastf 2020-02-0421:37:12.964610:Wtensorflow/stream_executor/platform/default/dso_loader.cc:55]Couldnotloaddynamiclibrary'libnvinfer.so.6';dlerror:libnvinfer.so.6:cannotopensharedobjectfile:Nosuchfileordirectory;LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/lib64 2020-02-0421:37:12.964749:Wtensorflow/stream_executor/platform/default/dso_loader.cc:55]Couldnotloaddynamiclibrary'libnvinfer_plugin.so.6';dlerror:libnvinfer_plugin.so.6:cannotopensharedobjectfile:Nosuchfileordirectory;LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/lib64 2020-02-0421:37:12.964777:Wtensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30]CannotdlopensomeTensorRTlibraries.IfyouwouldliketouseNvidiaGPUwithTensorRT,pleasemakesurethemissinglibrariesmentionedaboveareinstalledproperly. >>>print(tf.test.is_gpu_available()) WARNING:tensorflow:From:1:is_gpu_available(fromtensorflow.python.framework.test_util)isdeprecatedandwillberemovedinafutureversion. Instructionsforupdating: Use`tf.config.list_physical_devices('GPU')`instead. 2020-02-0421:37:37.267421:Itensorflow/core/platform/profile_utils/cpu_utils.cc:94]CPUFrequency:1795795000Hz 2020-02-0421:37:37.268461:Itensorflow/compiler/xla/service/service.cc:168]XLAservice0x55913b67a840initializedforplatformHost(thisdoesnotguaranteethatXLAwillbeused).Devices: 2020-02-0421:37:37.268516:Itensorflow/compiler/xla/service/service.cc:176]StreamExecutordevice(0):Host,DefaultVersion 2020-02-0421:37:37.272139:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcuda.so.1 2020-02-0421:37:37.481038:Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981]successfulNUMAnodereadfromSysFShadnegativevalue(-1),buttheremustbeatleastoneNUMAnode,soreturningNUMAnodezero 2020-02-0421:37:37.481712:Itensorflow/compiler/xla/service/service.cc:168]XLAservice0x55913b6eb960initializedforplatformCUDA(thisdoesnotguaranteethatXLAwillbeused).Devices: 2020-02-0421:37:37.481755:Itensorflow/compiler/xla/service/service.cc:176]StreamExecutordevice(0):GeForceGTX10603GB,ComputeCapability6.1 2020-02-0421:37:37.482022:Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981]successfulNUMAnodereadfromSysFShadnegativevalue(-1),buttheremustbeatleastoneNUMAnode,soreturningNUMAnodezero 2020-02-0421:37:37.482528:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1555]Founddevice0withproperties: pciBusID:0000:03:00.0name:GeForceGTX10603GBcomputeCapability:6.1 coreClock:1.7085GHzcoreCount:9deviceMemorySize:5.93GiBdeviceMemoryBandwidth:178.99GiB/s 2020-02-0421:37:37.482953:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcudart.so.10.1 2020-02-0421:37:37.485492:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcublas.so.10 2020-02-0421:37:37.487486:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcufft.so.10 2020-02-0421:37:37.487927:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcurand.so.10 2020-02-0421:37:37.490469:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcusolver.so.10 2020-02-0421:37:37.491950:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcusparse.so.10 2020-02-0421:37:37.499031:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcudnn.so.7 2020-02-0421:37:37.499301:Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981]successfulNUMAnodereadfromSysFShadnegativevalue(-1),buttheremustbeatleastoneNUMAnode,soreturningNUMAnodezero 2020-02-0421:37:37.500387:Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981]successfulNUMAnodereadfromSysFShadnegativevalue(-1),buttheremustbeatleastoneNUMAnode,soreturningNUMAnodezero 2020-02-0421:37:37.500847:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1697]Addingvisiblegpudevices:0 2020-02-0421:37:37.500941:Itensorflow/stream_executor/platform/default/dso_loader.cc:44]Successfullyopeneddynamiclibrarylibcudart.so.10.1 2020-02-0421:37:37.502172:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1096]DeviceinterconnectStreamExecutorwithstrength1edgematrix: 2020-02-0421:37:37.502212:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1102]0 2020-02-0421:37:37.502229:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1115]0:N 2020-02-0421:37:37.502436:Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981]successfulNUMAnodereadfromSysFShadnegativevalue(-1),buttheremustbeatleastoneNUMAnode,soreturningNUMAnodezero 2020-02-0421:37:37.503003:Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981]successfulNUMAnodereadfromSysFShadnegativevalue(-1),buttheremustbeatleastoneNUMAnode,soreturningNUMAnodezero 2020-02-0421:37:37.503593:Itensorflow/core/common_runtime/gpu/gpu_device.cc:1241]CreatedTensorFlowdevice(/device:GPU:0with2934MBmemory)->physicalGPU(device:0,name:GeForceGTX10603GB,pcibusid:0000:03:00.0,computecapability:6.1) True >>>
返回的True,说明可以
通过pycharm却不行,如下图,返回False
解决办法:
1.修改~/.bashrc
将pycahrm的路径加到环境中,示例如下:
aliaspycharm="bash/home/answer/文档/pycharm-professional-2019.3.2/pycharm-2019.3.2/bin/pycharm.sh"
刷新生效:
source~/.bashrc
2.修改pycharm中的环境变量
选择pycharm菜单栏Run——>Run-EditConfigurations——>Environmentvariables——>将cuda的路径加进去例如:LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64
在运行就可以了
到此这篇关于解决Ubuntu18中的pycharm不能调用tensorflow-gpu的问题的文章就介绍到这了,更多相关pycharm不能调用tensorflow-gpu内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。