禁用GPU版本TensorFlow,切換到CPU版本TensorFlow。


#禁用gpu版本TensorFlow,因為CUDA號碼從0開始,這里直接讓CUDA使用-1的GPU,自然就無法使用gpu了。

代碼前面加入:

import os
os.environ["CUDA_VISIBLE_DEVICES"]="-1"    
import tensorflow as tf
Environment Variable Syntax    Results
CUDA_VISIBLE_DEVICES=1    Only device 1 will be seen
CUDA_VISIBLE_DEVICES=0,1    Devices 0 and 1 will be visible
CUDA_VISIBLE_DEVICES="0,1"    Same as above, quotation marks are optional
CUDA_VISIBLE_DEVICES=0,2,3    Devices 0, 2, 3 will be visible; device 1 is masked

 

如果安裝了GPU,默認使用GPU版本的TensorFlow
---------------------
作者:灣區人工智能
來源:CSDN
原文:https://blog.csdn.net/BTUJACK/article/details/82622966
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM