1.下载windows版本的anaconda
https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Windows-x86_64.exe
这里我安装到E盘,安装后需要更新到2.6.1版本
2.创建环境 TF215, python版本3.11.9
![](http://www.inhhh.com/blog/wp-content/uploads/2024/06/image-1-1024x774.png)
3.运行Anaconda Prompt
![](http://www.inhhh.com/blog/wp-content/uploads/2024/06/image-2.png)
4. 激活 TF215
conda acitvate TF215
5.安装cudatoolkit
conda install cudatoolkit=10.1
6. 安装cudnn
conda install cudnn=7.6
7.安装tensorflow
pip install tensorflow==2.15.0
8. 运行python
python
>> import tensorflow as tf
>> tf.__version__ #测试,显示TF版本
'2.15.0'
>>
9.下载PyCharm
https://www.jetbrains.com/pycharm/download/?section=windows
选择Community Edition版本
10. 安装PyCharm
11.新建一个py项目
import tensorflow as tf
tensorflow_version = tf.__version__
gpu_available = tf.config.list_physical_devices('GPU')
print(tf.test.is_built_with_cuda())
print("tf ver",tensorflow_version,"\tGPU available:", gpu_available)
a = tf.constant([1.0, 2.0], name ="a")
b = tf.constant([1.0, 2.0], name ="b")
result = tf.add(a,b,name="add")
print(result)
Hey people!!!!!
Good mood and good luck to everyone!!!!!