With the availability of huge amount of data for research and powerfull machines to run your code on, Machine Learning and Neural Networks is gaining their foot again and impacting us more than ever in our everyday lives. With huge players like Google opensourcing part of their Machine Learning systems like the TensorFlow software library for numerical computation, there are many options for someone interested in starting off with Machine Learning/Neural Nets to choose from. Caffe, a deep learning framework developed by the Berkeley Vision and Learning Center (BVLC) and its contributors, comes to the play with a fresh cup of coffee.
Freshly brewed !
Install the GitHub Extension for Visual Studio. From within Visual Studio you can open/clone the GitHub repository. From the Getting Started page under Open, you should have GitHub as an option. Login, and then either choose Caffe2 from the list (if you’ve forked it) or browse to where you cloned it. To make caffe available in your python install you can copy the C: Projects caffe python caffe folder into your site-packages folder. This will make the caffe package available to your python executable. (Side Question: If we are only using caffe/python/caffe, why was the build required at all?).
The following section is divided in to two parts. Caffe's documentation suggests you to install Anaconda Python distribution to make sure that you've installed necessary packages, with ease. If you're someone who do not want to install Anaconda in your system for some reason, I've covered that too. So in the first part you'll find information on how to install Caffe with Anaconda and in the second part you'll find the information for installing Caffe without Anaconda .
Please note that the following instructions were tested on my local machine and in two Chameleon Cloud Instances. However I cannot garuntee success for anyone. Please be ready to see some errors on the way, but I hope you won't stumble into any if you follow the directions as is.
My local machine and the instances I used are NOT equipped with GPU's. So the installation instrucions are strictly for non-GPU based or more clearly CPU-only systems running Ubuntu 14 trusty. However, to install it in a GPU based system, you just have to install CUDA and necessary drivers for your GPU. You can find the instructions in Stack Overflow or in the always go to friend Google.
Anaconda python distribution includes scientific and analytic Python packages which are extremely useful. The complete list of packages can be found here.
To install Anaconda, you have to first download the Installer to your machine. Go to this website to download the Installer. Scroll to the 'Anaconda for Linux' section and choose the installer to download depending on your system architecture.
Once you have the Installer in your machine, run the following code to install Anaconda.
@stavBodik You need to compile caffe of course. On windows you can use the VS or Ninja Generators but not make. I personnally recommand ninja since it will build much faster than VS. Conda create -n caffe python=3.7 REM activate the environment REM Depending on your conda version you may have to use activate caffe. Conda activate caffe REM add the anaconda channel to resolve all dependencies. Conda config -add channels anaconda REM Install caffe with cuda support or install caffe-cpu if you do not want CUDA support. Installing Caffe on Ubuntu (CPU-ONLY) 7 minute read First, to tell you guys the truth, I had no intention to write this post. You know, because I actually don’t have much experience with Caffe. And I am not some kind of experienced tech-guy who can deal with almost developing environment, either.
Install Caffe On Windows
If you fail to read the few lines printed after installation, you'll waste a good amount of your produtive time on trying to figure out what went wrong. An important line reads:
For this change to become active, you have to open a new terminal.
So, once the Anaconda installation is over, please open a new terminal. Period.
After opening a new terminal, to verify the installation type:
This should give you the current version of conda, thus verifying the installation. Now that's done !
Now we will install OpenBLAS.
Next go ahead and install Boost. More info on boost here
I faced a problem while installing boost in all my machines. I fixed it by including multiverse repository into the sources.list. Since playing with sources.list is not reccomended, follow the steps for a better alternative.
51 rows HashKiller.co.uk is a hash lookup service. This allows you to input a hash and search for its. OnlineHashCrack is a powerful hash cracking and recovery online service for MD5 NTLM Wordpress Joomla SHA1 MySQL OSX WPA. Password/Hashes Crack Send us your hashes here. We support MD5, NTLM, LM, MYSQL. Password length 8 characters are FREE. Example: the password 'test12!' (length = 7) will be FREE. Other costs 5€/$6.
The repo is saved to a temporary list named 'multiverse.list' in the /tmp folder. It is then copied to /etc/apt/sources.list.d/ folder. The file in /tmp folder is then removed. I found this fix in Stack Exchange fourm.
Now to install boost, run:
Now, let us install OpenCV. Go ahead and run:
Now let us install some dependencies of Caffe. Run the following:
Okay, that's it. Let us now download the Caffe. If you don't have git installed in your system yet, run this code really quick:
We will clone the official Caffe repository from Github.
Once the git is cloned, cd into caffe folder.
We will edit the configuration file of Caffe now. We need to do it to specify that we are using a CPU-only system. (Tell compiler to disable GPU, CUDA etc). For this, make a copy of the Makefile.config.example.
Great ! Now go ahead and open the Makefile.config in your favourite text editor (vi or vim or gedit or ..). Change the following:
Your Makefile.config should look something like this now: Makefile.config
Now that's done, let me share with you an error I came across. Our Makefile.config is okay. But while 'make'-ing / building the installation files, the hf5 dependeny gave me an error. This might not apply to you. I can't say for sure. The build required two files libhdf5_h1.so.10 and libhd5.so.10 but the files in the system were libhdf5_h1.so.7 and libhd5.so.7. I fixed this by doing the following:
We will now install the libraries listed in the requirements.txt file.
Now, we can safely build the files in the caffe directory. We will run the make process as 4 jobs by specifying it like -j4. More on it here
I hope the make process went well. If not, please see which package failed by checking the logs or from terminal itself. Feel free to comment, I will help to the best of my knowledge. You can seek help from your go to friend Google or Stack Exchange as mentioned above.
Provided that the make process was successfull, continue with the rest of the installation process.
We will now make the Pycaffe files. Pycaffe is the Python interface of Caffe which allows you to use Caffe inside Python. More on it here. We will also make distribute. This is explained in Caffe website.
Awesome! We are almost there. We just need to test whether everything went fine. For that make the files for testing and run the test.
If you succeed in all the tests then you've successfully installed Caffe in your system ! One good reason to smile !
Finally, we need to add the correct path to our installed modules. Using your favourite text editor, add the following to the .bashrc file in your /home/user/ folder for Caffe to work properly. Please make sure you replace the < username > with your system's username.
CHEERS ! You're done ! Now let's test if it really works.
Restart/reboot your system to ensure everything loads perfect.
Open Python and type:
You should be able to successfully load caffe.Now let's start coding :)
By preference, if you don't want to install Anaconda in your system, you can install Caffe by following the steps below. As mentioned earlier, installing all the dependencies can be difficult. If this tutorial does not work for you, please look into the errors, use our trusted friends.
To start with, we will update and upgrade the packages in our system. Then we will have to install the dependencies one by one on the machine. Type the following to get started.
Now, let us install openblas.
Next go ahead and install Boost. More info on boost here
I faced a problem while installing boost in all my machines. I fixed it by including multiverse repository into the sources.list. Since playing with sources.list is not reccomended, follow the steps for a better alternative.
The repo is saved to a temporary list named 'multiverse.list' in the /tmp folder. It is then copied to /etc/apt/sources.list.d/ folder. The file in /tmp folder is then removed. I found this fix in Stack Exchange fourm.
Now to install boost, run:
If later in the installation process you find that any of the boost related files are missing, run the following command. You can skip this one for now but won't hurt if you do it either.
Go ahead and install libfaac-dev package.
Now, we need to install ffmpeg. Let us also make sure that the ffmpeg version is one which OpenCV and Caffe approves. We will remove any previous versions of ffmpeg and install new ones.
The following code will remove ffmpeg and related packages:
The mc3man repository hosts ffmpeg packages. I came to know about it from Stack Exchange forums. To include the repo, type this:
Update and install ffmpeg.
Now, we can install OpenCV. First let us install the dependencies. Building OpenCV can be challenging at first, but if you have all the dependencies correct it will be done in no time.
Go ahead and run the following lines:
The 'build-essential' ensures that we have the compilers ready. Now we will install some required packages. Run:
We will install some optional packages as well. Run:
Now we can go ahead and download the OpenCV build files. Go to your root folder first.
Download the files:
Unzip the file by:
Go to the opencv folder by running:
Make a build directory inside.
Go inside the build directory.
Build the files using cmake.
Anaconda Caffe Install Windows 10
In the summary, make sure that FFMPEG is installed, also check whether the Python, Numpy, Java and OpenCL are properly installed and recognized.
Now we will run the make process as 4 jobs by specifying it like -j4. More on it here
Go ahead and continue installation.
Once the installation is complete, do these steps to get OpenCV configured.
Come out of the build folder if you haven't already by running:
Install python-pip:
Now, we will install the Scipy and other scientific packages which are key Caffe dependencies.
We will install Cython now. (I wanted it to install scikit-image properly)
Now that we have Cython, go ahead and run the code below to install Scikit Image and Scikit Learn.
We will now install some more crucial dependencies of Caffe
Installing Pydot will be beneficial to view our net by saving it off in an image file.
Now that all the dependencies are installed, we will go ahead and download the Caffe installation files. Go ahead and run:
Go into the caffe folder and copy and rename the Makefile.config.example file to Makefile.config.
Great ! Now go ahead and open the Makefile.config in your favourite text editor (vi or vim or gedit or ..). Change the following:
We will install the packages listed in Caffe's requirements.txt file as well; just in case.
Now, we can safely build the files in the caffe directory. We will run the make process as 4 jobs by specifying it like -j4. More on it here
I hope the make process went well. If not, please see which package failed by checking the logs or from terminal itself. Feel free to comment, I will help to the best of my knowledge. You can seek help from your go to friend Google or Stack Exchange as mentioned above.
Provided that the make process was successfull, continue with the rest of the installation process.
We will now make the Pycaffe files. Pycaffe is the Python interface of Caffe which allows you to use Caffe inside Python. More on it here. We will also make distribute. This is explained in Caffe website.
Awesome! We are almost there. We just need to test whether everything went fine. For that make the files for testing and run the test.
If you succeed in all the tests then you've successfully installed Caffe in your system ! One good reason to smile !
Finally, we need to add the correct path to our installed modules. Using your favourite text editor, add the following to the .bashrc file in your /home/user/ folder for Caffe to work properly. Please make sure you replace the < username > with your system's username.
CHEERS ! You're done ! Now let's test if it really works.
Restart/reboot your system to ensure everything loads perfect.
Open Python and type:
You should be able to successfully load caffe. Now let's start coding :)
Makefile.configFor Caffe + AnacondaFor Caffe without Anaconda
Caffe is a deep learning framework made with expression, speed, and modularity in mind.It is developed by Berkeley AI Research (BAIR)/The Berkeley Vision and Learning Center (BVLC) and community contributors.
Check out the project site for all the details like
and step-by-step examples.
Windows Setup
Requirements: Visual Studio 2015, CUDA 9.0, third party libraries: Baidu Yun or Google Drive. Please extract the archive into
./windows/thirdparty/ . Then, add the folder ./windows/thirdparty/bins to the environment variable PATH .
Pre-Build Steps
Copy
.windowsCommonSettings.props.example to .windowsCommonSettings.props
By defaults Windows build requires
CUDA and cuDNN libraries.Both can be disabled by adjusting build variables in .windowsCommonSettings.props .Python support is disabled by default, but can be enabled via .windowsCommonSettings.props as well.
CUDA
Download
CUDA Toolkit 8.0 from nVidia website.If you don't have CUDA installed, you can experiment with CPU_ONLY build.In .windowsCommonSettings.props set CpuOnlyBuild to true and set UseCuDNN & UseNCCL to false .
cuDNN
Download
cuDNN v5 from nVidia website.Unpack downloaded zip to %CUDA_PATH% (environment variable set by CUDA installer).Alternatively, you can unpack zip to any location and set CuDnnPath to point to this location in .windowsCommonSettings.props .CuDnnPath defined in .windowsCommonSettings.props .Also, you can disable cuDNN by setting UseCuDNN to false in the property file.
Installing Caffe For Windows Python Windows 7Python
To build Caffe Python wrapper set
PythonSupport to true in .windowsCommonSettings.props .Download Miniconda 2.7 64-bit Windows installer [from Miniconda website] (http://conda.pydata.org/miniconda.html).Install for all users and add Python to PATH (through installer).
Run the following commands from elevated command prompt:
Remark
After you have built solution with Python support, in order to use it you have to either:
Matlab
To build Caffe Matlab wrapper set
MatlabSupport to true and MatlabDir to the root of your Matlab installation in .windowsCommonSettings.props .
Remark
After you have built solution with Matlab support, in order to use it you have to add the
./matlab folder to Matlab search path.
Build
Now, you should be able to build
.windowsCaffe.sln
License and Citation
Caffe is released under the BSD 2-Clause license.The BAIR/BVLC reference models are released for unrestricted use.
Please cite Caffe in your publications if it helps your research:
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |