Caffe error when installing through anaconda - python

I'm struggling to just install and import Caffe on my windows 10's Anaconda. I really don't know why such a well-known deep-learning package is that hard to just install!
First, I tried to install it. With huge difficulties, I did the following and at last, apparently, the installation was successful:
conda create -n caffe python=3.7
// activate the environment REM Depending on your conda version you may have to use activate Caffe
conda activate caffe
// add the anaconda channel to resolve all dependencies
conda config --add channels anaconda
// Install caffe with cuda support or install caffe-cpu if you do not want CUDA support
conda install caffe-cpu -c willyd
And now, just trying to import caffe, I get this error:
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Continuum\anaconda3\envs\caffe\lib\site-packages\caffe\__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "C:\Users\user\AppData\Local\Continuum\anaconda3\envs\caffe\lib\site-packages\caffe\pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: DLL load failed: The specified module could not be found.
What should I do? How to fix it?

Related

error: cannot import name 'model_lib_v2' from 'object_detection' [duplicate]

I'm trying to train TF2 for object detection. When I run model_main_tf2.py, I get the following error:
Traceback (most recent call last):
File "C:\Python_venv\trained_models\model_main_tf2.py", line 32, in <module>
from object_detection import model_lib_v2
ImportError: cannot import name 'model_lib_v2' from 'object_detection' (c:\Python_venv\tensorflow\lib\site-packages\object_detection\__init__.py)
How do I install model_lib_v2?
I tried reinstalling TF and reinstalling TensorFlow-object-detection-API but no luck. I went all over the internet looking for answers.
I found:
https://github.com/tensorflow/models/issues/7920
But they don't say how to install model_lib_v2
Unfortunately I cannot use TF1, the goal is to use TF2.
see https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md
git clone https://github.com/tensorflow/models.git
## Python Package Installation
cd models/research
### Compile protos.
protoc object_detection/protos/*.proto --python_out=.
### Install TensorFlow Object Detection API.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --user --use-feature=2020-resolver .
You should be able to just go to line 32 in "C:\Python_venv\trained_models\model_main_tf2.py" and remove "from object_detection", since you are already inside the package.
replace:
"from object_detection import model_lib_v2"
by:
"import model_lib_v2"

How to install tensorflow without pip in the right way?

So I have installed tensorflow with pip using pip install tensorflow==1.15 a few days ago, today I wanted to search for my models-master file and I didn't find it. I uninstalled tensorflow using pip uninstall tensorflow and then I installed it from the github and added it to the folder of the project I am working on like, it is in the same folder as the .py files of my original project. This is because I need to use protoc on the files because I got error messages before. I think I got the protoc part down now but I can't test it, because whenever I want to run my main file, I get this error message:
Traceback (most recent call last):
File "C:\Users\user\Desktop\captcha solver\main_.py", line 1, in <module>
from CAPTCHA_object_detection import *
File "C:\Users\user\Desktop\captcha solver\CAPTCHA_object_detection.py", line 18, in <module>
from object_detection.utils import ops as utils_ops
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection\utils\ops.py", line 291, in <module>
dtype=tf.float32):
AttributeError: module 'tensorflow' has no attribute 'float32'
I think this is because of the way I installed tensorflow, but I don't know what I did wrong, I have never installed modules without pip though.

AttributeError: module 'tensorboard.util' has no attribute 'PersistentOpEvaluator' , when trying to use TensorBoard

I made some log files using tensorboard but I can't access them.
Using
tensorboard or tensorboard --logdir=logs/ on the command prompt
gives the following error:-
C:\Users\User>tensorboard
Traceback (most recent call last):
File "C:\Users\User\Anaconda3\Scripts\tensorboard-script.py", line 6, in <module>
from tensorboard.main import run_main
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\main.py", line 40, in <module>
from tensorboard import default
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\default.py", line 38, in <module>
from tensorboard.plugins.beholder import beholder_plugin
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\__init__.py", line 15, in <module>
from tensorboard.plugins.beholder.beholder import Beholder
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\beholder.py", line 25, in <module>
from tensorboard.plugins.beholder import im_util
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\im_util.py", line 89, in <module>
class PNGDecoder(util.PersistentOpEvaluator):
AttributeError: module 'tensorboard.util' has no attribute 'PersistentOpEvaluator'
I tried this solution, but it did not help.
I also had a big fight with this problem. What eventually worked for me was the following:
pip uninstall tensorflow
pip uninstall tensorboard
conda show OR pip show --> have a look at which other tensorflow related packages you have installed and remove them.
Go to site-packages and remove tensorflow/tensorboard folders (look for any folder in your filesystem related to a tensorflow / tensorboard installation)
conda clean --all (not sure if this is necessary, but it was one of
my steps and might be relevant)
Reinstall tensorflow and tensorboard. Preferably use conda as it is faster by several orders of magnitude
One of my main sources in solving this issue was this github issue thread:
https://github.com/tensorflow/tensorboard/issues/1724
Try to install these packages with Conda Run:
conda install -c anaconda tensorflow-gpu
conda install -c anaconda keras

Install python caffe with anaconda2 (pycaffe)

I'm trying to to be able to run this demo https://github.com/ZheC/Realtime_Multi-Person_Pose_Estimation
I'm running ubuntu 14.04
I have installed Anaconda, and after installing many many many dependencies another one pops. It also requires python caffe
So I installed it with this command:
(I also tried Pip install caffe but if failed)
Conda install caffe
But then when I try to run it I get:
$python
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gtkratosman-lap/anaconda2/lib/python2.7/site-packages/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/gtkratosman-lap/anaconda2/lib/python2.7/site-packages/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: libprotobuf.so.12: cannot open shared object file: No such file or directory
I have been able to verify this behaviour in my own Anaconda environment running conda v4.3.27 in a Python v2.7.14 virtual environment, installing caffe v1.0.0rc5.
Having looked further into the issue, it seems it relates to the following open Anaconda issue: caffe needs to pin protobuf requirement to version #6733
As described in the issue:
The caffe and caffe-gpu package in defaults has a requirement on protobuf without any version dependencies. Unfortunately, the caffe packages links to libprotobuf.so.12 which is provided by the protbuf version 3.2.0
As such, I found I was able to successfully import caffe in Python, running in my Anaconda virtual environment, by first manually installing protobuf v3.2.0, as follows: conda install protobuf==3.2.0

xgboost installation issue with anaconda

I am using Anaconda. I first switched to Python2 (Version 2.7.11).
python -V
Python 2.7.11 :: Continuum Analytics, Inc.
I used the following command to install xgboost in anaconda.
conda install -c https://conda.anaconda.org/akode xgboost
I then checked that xgboost is installed.
conda list
xgboost 0.3 py27_0 akode
I run python in terminal, import xgboost and got the following errors.
import xgboost as xgb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/envs/wen2/lib/python2.7/site-packages/xgboost.py", line 82, in <module>
xglib = load_xglib()
File "//anaconda/envs/wen2/lib/python2.7/site-packages/xgboost.py", line 59, in load_xglib
lib = ctypes.cdll.LoadLibrary(lib_path[0])
File "//anaconda/envs/wen2/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "//anaconda/envs/wen2/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(//anaconda/envs/wen2/lib/python2.7/site-packages/libxgboostwrapper.so, 6): Library not loaded: #rpath/./libgomp.1.dylib
Referenced from: //anaconda/envs/wen2/lib/python2.7/site-packages/libxgboostwrapper.so
Reason: image not found
I have no idea what to do next.
The package image you download is corrupt.
What you should do :
First remove your xgboost package with (in the terminal) :
conda remove xgboost
Then reinstall with an other package at https://anaconda.org/aterrel/xgboost
So just write :
conda install py-xgboost
Then you can check the installation in the python console :
import xgboost
It should be ok.
I had the same error. I completely uninstalled xgboost by pip unistall. then installed it back by:
conda install -c bioconda xgboost=0.6a2
This seems to solve the problem
You first need to build the library through "make", then you can install using anaconda prompt.
First follow the official guide with the following procedure (in Git Bash on Windows):
git clone --recursive https://github.com/dmlc/xgboost
git submodule init
git submodule update
install TDM-GCC here
alias make='mingw32-make'
cp make/mingw64.mk config.mk; make -j4
Last, do the following using anaconda prompt:
cd xgboost\python-package
python setup.py install
Also refer to these great resources:
Official Guide
Installing Xgboost on Windows
Installing XGBoost For Anaconda on Windows
Did you try using pip?
source activate yourenvironment
pip install xgboost
Library not loaded: #rpath/./libgomp.1.dylib
This is the key.
In my case, it is " Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib"
I check my path "/usr/local/opt/gcc/lib/gcc"
and there is only a folder named 7 there , no 6.
So i use "sudo find / -name libgomp.1.dylib" to locate all the gcc version i have installed, with I found that there is a version 6 in another location.
Then I create a folder named 6 under '/usr/local/opt/gcc/lib/gcc' and copy those gcc 6 files in there .
Finally , "import xgboost" works with no error .
I had a similar problem
>>> import xgboost
/usr/local/anaconda2/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/anaconda2/lib/python2.7/site-packages/xgboost/__init__.py", line 11, in <module>
from .core import DMatrix, Booster
File "/usr/local/anaconda2/lib/python2.7/site-packages/xgboost/core.py", line 112, in <module>
_LIB = _load_lib()
File "/usr/local/anaconda2/lib/python2.7/site-packages/xgboost/core.py", line 106, in _load_lib
lib = ctypes.cdll.LoadLibrary(lib_path[0])
File "/usr/local/anaconda2/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "/usr/local/anaconda2/lib/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/local/anaconda2/bin/../lib/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/local/anaconda2/lib/python2.7/site-packages/xgboost/./lib/libxgboost.so)
In my case the problem is that i installed xgboost with a regular user. So i did
sudo su
pip uninstall xgboost
pip install xgboost
python
>>> import xgboost
/usr/local/anaconda2/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
>>> ~
Hope this can help!
in the my ubuntu 14.04,
first: install anaconda
second: git clone the xgboost, and make and install, complie the python package
third: setup the xgboost with anaconda. for example:
1) cd yourpath/xgboost/python-package
2) find you anaconda python python path:
anaconda/bin/python setup.py install

Categories