Building Tensorflow 2.0 from source - tensorflow

I've built Tensorflow 2.0 from source using the below commands:
-march=native -Wno-sign-compare -mssse3 -mcx16 -msse4.1 -msse4.2 -mpopcnt -mno-avx
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package --local_ram_resources=1024 --jobs=1 --define=tf_api_version=2
The build apparently completed successfully, that is without any errors, but when I go to install, using the below command:
python /tensorflow/tools/pip_package/setup.py install
It installs the egg in site-packages and checks for dependencies, but does nothing else. Nor does it return any error. The end of the output is below:
Searching for Markdown==3.1.1
Best match: Markdown 3.1.1
Adding Markdown 3.1.1 to easy-install.pth file
Installing markdown_py script to /var/...
Using /var/.../python3.6/site-packages
Searching for h5py==2.9.0
Best match: h5py 2.9.0
Adding h5py 2.9.0 to easy-install.pth file
Using /var/.../python3.6/site-packages
Finished processing dependencies for tensorflow==2.0.0rc0
and of course when I run python:
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
What am I missing here?

I could not comment at the moment. Can you verify the installation is done successfully ? That is after running:
python /tensorflow/tools/pip_package/setup.py install
you can check the folder tensorflow package in Python lib folders.

Related

Failed to import cupy

After installing cupy via "pip install cupy-cuda110", I tried this in python3:
import cupy as cp
However, it failed:
"
$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import cupy as cp
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/cupy/init.py", line 18, in
from cupy import _core # NOQA
File "/usr/local/lib/python3.8/dist-packages/cupy/_core/init.py", line 1, in
from cupy._core import core # NOQA
ImportError: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/cupy/init.py", line 20, in
raise ImportError(f'''
ImportError:
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
"
May you know how to resolve this problem? Many thanks!
Before installing cupy, you should check the version of Cuda that is installed on your device :
!nvcc --version
For me, the Cuda version installed on my device is 11.0 (See the picture below) :
After that go to the official Cupy website https://docs.cupy.dev/en/stable/install.html
The following image is from the page I referred to above:
Then type the install command that matches your Cuda version, for me, the install command will be :
pip install cupy-cuda110
When installing these packages with CUDA 11.2, 11.3, or 11.4, you may experience a “Failed to import CuPy” error. To resolve this error, please uninstall cupy-cuda115 and install cupy-cuda11x:
pip uninstall cupy-cuda115
pip install cupy-cuda11x
https://rapids.ai/pip.html

Cant run modules

everytime after downloading a module a cant run it, what im doing wrong?
I've installed it using:
pip install pyperclip
It has been installed succesfully:
C:\WINDOWS\system32>pip list
Package Version
--------------- ---------
certifi 2020.6.20
clipboard 0.0.4
colorama 0.4.3
cycler 0.10.0
handcalcs 0.8.1
kiwisolver 1.2.0
matplotlib 3.3.1
numpy 1.19.1
Pillow 7.2.0
pip 20.2.3
pyparsing 2.4.7
pyperclip 1.7.0
python-dateutil 2.8.1
qrcode 6.1
six 1.15.0
sqrc 0.0.3
But when running the code, this is what a get:
import pyperclip
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
Any help on this?
That can be specific for a programming platform you are using. Some platforms like PyCharm enable to install modules directly from themselves so using modules becomes much easier.

ModuleNotFoundError: No module named 'tensorflow' after installing on Mac OS

I have followed the installation instruction on https://www.tensorflow.org/install/install_mac
for Tensorflow virtualenv (as recommended).
pip3 install --upgrade virtualenv
virtualenv --system-site-packages -p python3
The installation was painless without error messages.
I activate tensorflow and move to a different directory to avoid confusion with tensorflow directory name when importing tensorflow to Python. The result is:
source ~/tensorflow/bin/activate
(tensorflow) Pers-MacBook-Pro:Documents per$ python3
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
What is wrong? I'm on MacOS Sierra. I ran the diagnostics script tf_env_collect.sh to provide some more info about the environment:
== check pips ===================================================
numpy (1.13.3)
protobuf (3.4.0)
tensorflow (1.3.0)
tensorflow-tensorboard (0.1.8)
== check for virtualenv =========================================
True
== tensorflow import ============================================
tf.VERSION = 1.3.0
tf.GIT_VERSION = v1.3.0-rc2-20-g0787eee
tf.COMPILER_VERSION = v1.3.0-rc2-20-g0787eee
Sanity check: array([1], dtype=int32)
== env ==========================================================
LD_LIBRARY_PATH is unset
DYLD_LIBRARY_PATH is unset
== nvidia-smi ===================================================
./tf_env_collect.sh: line 105: nvidia-smi: command not found
== cuda libs ===================================================
I found the reason: TensorFlow requires the Python package six, and the version included in Apple's default Python installation is too old.
Solution: Upgrade the Python installation with the current version of six:
$ sudo easy_install -U six

Error importing pygtk with Anaconda

OS: Ubuntu 15.10
I had no problem importing pygtk with default Python interpreter. However I wasn't able to do so using the Anaconda interpreter.
Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Dec 6 2015, 18:08:32)
[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 pygtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pygtk
I also couldn't get it to work after installing the pygtk with conda.
/opt/anaconda2/pkgs$ conda info --env
Using Anaconda Cloud api site https://api.anaconda.org
# conda environments:
#
root * /opt/anaconda2
/opt/anaconda2/pkgs$ conda list -n root|grep pygtk
pygtk 2.16.0 1 ska
As you can see from the output that pygtk pkg is available under the root env.
Any ideas what I have missed or done incorrectly?
I've haven't had success with ska/pygtk, but mw/pygtk2 worked for me:
conda install -c https://conda.anaconda.org/mw pygtk2
Other details here

Can't find Python modules after Time Machine restore

Recently, I performed a clean install of OS X Mountain Lion and restored my system from a Time Machine backup. When I tried to use python, it was unable to find most of the modules that I had installed before I wiped my OS. It also appears that the Xcode Command Line Tools were no longer on the system.
I reinstalled the Xcode Command Line Tools and pip (using easy_install), and went to work reinstalling the modules I use, starting with numpy. However, pip said it was already installed:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
However, in the CLI for Python, it still can't find numpy:
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
I've tried to install some other modules. When I installed ujson with pip, everything went fine, and python found it with no problems. However, when I tried to install matplotlib with pip, clang threw an error and it failed to install. I think the problem might be that matplotlib has dependency on numpy, but I don't know.
In file included from src/ft2font.cpp:3:
src/ft2font.h:16:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lqNcmF-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/matplotlib`
Any advice on how to resolve this issue? Should I just uninstall this other version of numpy, or do you think this is a deeper issue?
Deleting the numpy files in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python and reinstalling numpy would be my suggestion. It seems like the libraries are no longer being linked to properly even though the files are there.