报错
import tensorflow as tf
Segmentation fault (core dumped)
conda 环境下 python 版本
(base) 22@111:~$ python -V
Python 3.7.11
查看 pip 安装的库
pip list
Anaconda的python版本是3.7的,我们创建一个Python的虚拟环境以支持TensorFlow
(base) 22@111:~$ conda create --name tf python=3.6
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/wym/project/cpu_gpu/anaconda3/envs/tf
added / updated specs:
- python=3.6
The following packages will be downloaded:
package | build
---------------------------|-----------------
_openmp_mutex-4.5 | 1_gnu 22 KB
ca-certificates-2021.10.26 | h06a4308_2 115 KB
certifi-2020.6.20 | pyhd3eb1b0_3 155 KB
ncurses-6.3 | h7f8727e_2 782 KB
pip-21.2.2 | py36h06a4308_0 1.8 MB
python-3.6.13 | h12debd9_1 32.5 MB
setuptools-58.0.4 | py36h06a4308_0 788 KB
------------------------------------------------------------
Total: 36.1 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex pkgs/main/linux-64::_openmp_mutex-4.5-1_gnu
ca-certificates pkgs/main/linux-64::ca-certificates-2021.10.26-h06a4308_2
certifi pkgs/main/noarch::certifi-2020.6.20-pyhd3eb1b0_3
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.35.1-h7274673_9
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng pkgs/main/linux-64::libgcc-ng-9.3.0-h5101ec6_17
libgomp pkgs/main/linux-64::libgomp-9.3.0-h5101ec6_17
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.3.0-hd4cf53a_17
ncurses pkgs/main/linux-64::ncurses-6.3-h7f8727e_2
openssl pkgs/main/linux-64::openssl-1.1.1l-h7f8727e_0
pip pkgs/main/linux-64::pip-21.2.2-py36h06a4308_0
python pkgs/main/linux-64::python-3.6.13-h12debd9_1
readline pkgs/main/linux-64::readline-8.1-h27cfd23_0
setuptools pkgs/main/linux-64::setuptools-58.0.4-py36h06a4308_0
sqlite pkgs/main/linux-64::sqlite-3.36.0-hc218d9a_0
tk pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0
wheel pkgs/main/noarch::wheel-0.37.0-pyhd3eb1b0_1
xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
zlib pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3
Proceed ([y]/n)?
Downloading and Extracting Packages
pip-21.2.2 | 1.8 MB | ################################################################################################################## | 100%
_openmp_mutex-4.5 | 22 KB | ################################################################################################################## | 100%
python-3.6.13 | 32.5 MB | ################################################################################################################## | 100%
ca-certificates-2021 | 115 KB | ################################################################################################################## | 100%
setuptools-58.0.4 | 788 KB | ################################################################################################################## | 100%
certifi-2020.6.20 | 155 KB | ################################################################################################################## | 100%
ncurses-6.3 | 782 KB | ################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate tf
#
# To deactivate an active environment, use
#
# $ conda deactivate
conda remove --name tf --all #删除tf环境(全部删除)
(base) 22@111:~$ conda activate tf
(tf) 22@111:~$ pip list
Package Version
---------- ---------
certifi 2020.6.20
pip 21.2.2
setuptools 58.0.4
wheel 0.37.0
安装TensorFlow
pip install tensorflow==1.5.0
测试
(tf) 22@111:~$ python
Python 3.6.13 |Anaconda, Inc.| (default, Jun 4 2021, 14:25:59)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>>