기본 tensorflow 예제 실행 오류
우분투에 최신 tensorflow를 다시 설치했습니다.
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
[sudo] password for ubuntu:
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tensorflow==0.7.1 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl (13.8MB)
100% |████████████████████████████████| 13.8MB 32kB/s
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: protobuf==3.0.0b2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: wheel in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: numpy>=1.8.2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf==3.0.0b2->tensorflow==0.7.1)
Installing collected packages: tensorflow
Found existing installation: tensorflow 0.7.1
Uninstalling tensorflow-0.7.1:
Successfully uninstalled tensorflow-0.7.1
Successfully installed tensorflow-0.7.1
테스트 지침을 따를 때 pywrap_tensorflow 이름을 가져올 수 없으므로 실패합니다 .
$ ipython
/git/tensorflow/tensorflow/__init__.py in <module>()
21 from __future__ import print_function
22
---> 23 from tensorflow.python import *
/git/tensorflow/tensorflow/python/__init__.py in <module>()
43 _default_dlopen_flags = sys.getdlopenflags()
44 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 45 from tensorflow.python import pywrap_tensorflow
46 sys.setdlopenflags(_default_dlopen_flags)
47
ImportError: cannot import name pywrap_tensorflow
파이썬 또는 우분투 / bash 환경에 추가 변경이 필요합니까?
스택 추적 ( /git/tensorflow/tensorflow/…) 의 경로에서 Python 경로가 설치 한 버전이 아닌 소스 디렉터리에서 tensorflow 라이브러리를로드하는 것처럼 보입니다. 결과적으로 pywrap_tensorflow다른 디렉토리에 설치된 (컴파일 된) 라이브러리 를 찾을 수 없습니다 .
일반적인 솔루션이다 cd의 밖으로 /git/tensorflow시작하기 전에 디렉토리 python나 ipython.
아래 명령이 도움이되었습니다.
pip install tensorflow --upgrade --force-reinstall
Python 2.7 가상 환경 (venv)의 소스 (GitHub : https://github.com/tensorflow/tensorflow )에서 TensorFlow를 컴파일하고 설치했습니다 . 잘 작동했지만 Tensorflow 를 가져올 수 있으려면 내가 TensorFlow를 컴파일 한 파티션에서 다른 파티션으로 cd 아웃 ( 예 : Error running basic tensorflow example 에서 사용자 "mrry"라고 언급했듯이 ) 필요했습니다. 파이썬으로. 그렇지 않으면 내가 어느 (소스 파티션) 디렉토리에 있었는지에 따라 다양한 오류가 발생했습니다.
source: /mnt/Vancouver/apps/tensorflow
can't import tf: Python launched in any of /mnt/...
can import tf: Python launched in /home/victoria/...
나중에 여기의 지침을 따랐습니다.
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#anaconda-installation
모든 것이 잘 작동합니다.
참고로 나는
- 아치 리눅스 [4.6.3-1-ARCH] x86_64
- 인텔 i7-4790
- xfce 4.12 데스크탑 환경
설치 단계 :
기본 설정에 따라 경로, venv 이름을 수정합니다.
tf-env를 만듭니다.
cd /home/victoria/anaconda3/envs conda create -n tf-env python=2.7 anaconda
Note: appending the 'anaconda' metapackage installs ALL Anaconda packages (NumPy; ...).
Source activate that venv (tf-env)
source activate tf-env
Note: added to ~/.bashrc as an alias:
alias tf='echo " [TensorFlow in Anaconda Python 2.7 venv (source activate tf]" && source activate tf-env'
Install TensorFlow in the tf-env venv:
(tf-env)$ conda install -c conda-forge tensorflow
THIS obviates the use of pip (including the *.whl install script), an alternative approach to installing TensorFlow that is described here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md).
WORKS!
(tf-env)[victoria@victoria ~]$ P
[P: python]
Python 2.7.12 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow
>>> print tensorflow.__version__
0.9.0
>>> [Ctrl-D]
(tf-env)[victoria@victoria ~]$
You may then work with TensorFlow in the tf-env; e.g., in Jupyter notebooks launched in this (tf-env) venv.
In my python -m venv environment it appeared to be fixed by:
pip uninstall tensorflow
Change requirements.txt to say tensorflow==1.5.0 instead of tensorflow==1.8.0.
pip install -r requirements.txt
if you using CPU manufactured before 2011 then downgraded the tensorflow version from 1.8.0 to 1.5.0 or 1.2.0 and try to import the module it worked for me.
Installing via the following command solves the problem:
pip install --upgrade
Here's the link to download
I figured out that TensorFlow 1.12.0 only works with Python version 3.5.2. I had Python 3.7 but that didn't work. So, I had to downgrade Python and then I could install TensorFlow it works.
To downgrade your python version from 3.7 to 3.6
conda install python=3.6.8
I'm using tensorflow 1.13.1. Just reinstalling tensorflow worked for me.
I also have this issue and have been looking into it for a long time. It seems that there is no such problem on python 3+. On py2.7- The problem is actually on google.protobuf
Solution 1:
pip uninstall protobuf
pip uninstall google
pip install google
pip install protobuf
pip install google-cloud
Solution 2:
create an __init__.py in "google" folder.
cd /path/to/your/env/lib/python2.7/site-packages/google
touch __init__.py
Hopefully it will work.
I resolve the problem. Try the follow command:
pip install --upgrade pip
참고URL : https://stackoverflow.com/questions/35953210/error-running-basic-tensorflow-example
'IT박스' 카테고리의 다른 글
| C # "finally"블록이 항상 실행됩니까? (0) | 2020.11.13 |
|---|---|
| 내 텍스트 영역의 자리 표시자가 표시되지 않는 이유는 무엇입니까? (0) | 2020.11.13 |
| 바이너리 파일의 처음 10 바이트 만 가져 오는 방법 (0) | 2020.11.13 |
| UDP를 사용하는 JavaScript WebSocket? (0) | 2020.11.12 |
| Reactive와 Functional-Reactive 프로그래밍의 차이점 (0) | 2020.11.12 |