官术网_书友最值得收藏!

AI源碼解讀.?dāng)?shù)字圖像處理案例:Python版

3.2.2 TensorFlow環(huán)境

安裝Anaconda后打開Anaconda Prompt。

(1)創(chuàng)建TensorFlow環(huán)境,與Python版本號進行匹配,輸入命令:

     conda create - n TensorFlow python=3.x

x的值根據(jù)實際情況決定,創(chuàng)建過程中有需要確認的地方,都輸入y。

(2)激活TensorFlow的環(huán)境,輸入命令:

     activate tensorflow

光標(biāo)前方出現(xiàn)(TensorFlow)則表示創(chuàng)建成功。

(3)安裝TensorFlow:

     CPU版本安裝,輸入命令:pip install --ignore-installed --upgrade tensorflow
     GPU版本安裝,輸入命令:pip install --ignore-installed --upgrade tensorflow-gpu

不能同時安裝CPU和GPU版本的TensorFlow。

以上命令會安裝最新版本的TensorFlow,未必需要,建議在后面跟上版本號,安裝指定版本的TensorFlow,輸入命令:

     pip install -- ignore-installed -- upgrade tensorflow==1.4.0

(4)如果安裝錯誤版本,先卸載之前安裝的TensorFlow,輸入命令:

     pip uninstall tensorflow
     pip uninstall tensorflow - gpu

(5)驗證TensorFlow安裝成功,輸入python進入編程環(huán)境,輸入命令:

     import tensorflow as tf
     hello = tf.constant('Hello, TensorFlow!')
     sess = tf.Session()
     print(sess.run(hello))

運行成功則證明安裝正確。

為快速安裝,在進行以上步驟前輸入清華倉庫鏡像,在Anaconda Prompt中,輸入命令:

     conda config -- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
     conda config –set show_channel_urls yes
主站蜘蛛池模板: 河间市| 安宁市| 临朐县| 大同市| 观塘区| 阿拉尔市| 美姑县| 新兴县| 新竹市| 分宜县| 齐齐哈尔市| 靖远县| 得荣县| 连南| 北流市| 望奎县| 松江区| 黔东| 菏泽市| 昌吉市| 田东县| 谢通门县| 南丰县| 砚山县| 佳木斯市| 兴宁市| 霍邱县| 潜江市| 双江| 凤庆县| 兴海县| 沅陵县| 泸水县| 乌鲁木齐市| 长岛县| 许昌县| 河南省| 崇文区| 连云港市| 淮滨县| 新田县|