<commit_before>---
layout: post
title: Install Caffe on Fedora 21 without Cuda
date: 2014-04-21 16:39
categories: 
    - deep learning
tags:
    - caffe
comments: true

---
[Caffe](https://github.com/BVLC/caffe) is a popular deep learning framework. 
Installing [caffe](https://github.com/BVLC/caffe) on fedora 21 is not very easy. 
One reason is that following the [official install instructions](http://caffe.berkeleyvision.org/installation.html) can't always make you successful.
Another reason is that fedora seems to be less popular than Ubuntu and there are few reports on how to solve some strange problems. 
During installation, I met with many problems. This post records these problems on X86\_64 fedora platform.  

[Cuda 7](https://developer.nvidia.com/cuda-downloads) is still not available on fedora 21. 
Cuda 6.5 can't be complied using the default gcc complier. 
Therefore, I don't install cuda and only use the cpu mode of caffe.   
##Basic Installation
First, follow the [fedora installing instruction](http://caffe.berkeleyvision.org/install_yum.html) to install dependency packages. 
##Problem 1
Then, enter the caffe directory and type ``cmake .``, You may be see the error below:
<pre>
 Could NOT find Atlas (missing: Atlas_LAPACK_LIBRARY)
 Call Stack (most recent call first):
 /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
       cmake/Modules/FindAtlas.cmake:43 (find_package_handle_standard_args)
          cmake/Dependencies.cmake:74 (find_package)
            CMakeLists.txt:26 (include)
</pre>
**Solution**  
In file **cmake/Modules/FindAtlas.cmake** line 31, we need to change  
<pre>
find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
</pre>
to  
<pre>
find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r alapack lapack_atlas lapack PATHS ${Atlas_LIB_SEARCH_PATHS})
</pre>
We add **lapack** in find\_library.  
##Using openblas
<pre>
cp Makefile.config.example Makefile.config
</pre>
Modify Makefile.config:
1. Comment Out Line 8.   
Change  
<pre>
\#CPU_ONLY=1
</pre>
to  
<pre>
CPU_ONLY=1
</pre>
2. Comment Out Line 15 to disable cuda.  
3. In Line 33, set BLAS to be open. (or you can use atlas. ) 
<pre>
BLAS:= open
</pre>
4. In Line 65, add **/usr/lib64/** to **LIBRARY\_DIRS**.   
<pre>
LIBRARY_DIRS := $(PYTHON\_LIB) /usr/local/lib /usr/lib /usr/lib64
</pre>
5. make
<pre>
make all
</pre>
##Problem 2
Maybe you will meet these problems.
<pre>
../lib/libcaffe.so: undefined reference to `cblas_sgemv'<commit_msg>finish caffe installing<commit_after>---
layout: post
title: Install Caffe on Fedora 21 without Cuda
date: 2014-04-21 16:39
categories: 
    - deep learning
tags:
    - caffe
comments: true

---
[Caffe](https://github.com/BVLC/caffe) is a popular deep learning framework. 
Installing [caffe](https://github.com/BVLC/caffe) on fedora 21 is not very easy. 
One reason is that following the [official install instructions](http://caffe.berkeleyvision.org/installation.html) can't always make you successful.
Another reason is that fedora seems to be less popular than Ubuntu and there are few reports on how to solve some strange problems. 
During installation, I met with many problems. This post records these problems on X86\_64 fedora platform.  

[Cuda 7](https://developer.nvidia.com/cuda-downloads) is still not available on fedora 21. 
Cuda 6.5 can't be complied using the default gcc complier. 
Therefore, I don't install cuda and only use the cpu mode of caffe.   
##Basic Installation
First, follow the [fedora installing instruction](http://caffe.berkeleyvision.org/install_yum.html) to install dependency packages. 
##Problem 1
Then, enter the caffe directory and type ``cmake .``, You may be see the error below:
<pre>
 Could NOT find Atlas (missing: Atlas_LAPACK_LIBRARY)
 Call Stack (most recent call first):
 /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
       cmake/Modules/FindAtlas.cmake:43 (find_package_handle_standard_args)
          cmake/Dependencies.cmake:74 (find_package)
            CMakeLists.txt:26 (include)
</pre>
**Solution**  
In file **cmake/Modules/FindAtlas.cmake** line 31, we need to change  
<pre>
find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
</pre>
to  
<pre>
find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r alapack lapack_atlas lapack PATHS ${Atlas_LIB_SEARCH_PATHS})
</pre>
We add **lapack** in find\_library.  
##Using openblas
<pre>
cp Makefile.config.example Makefile.config
</pre>
Modify Makefile.config:  
1. Comment Out Line 8.   
Change  
<pre>
\#CPU_ONLY=1
</pre>
to  
<pre>
CPU_ONLY=1
</pre>
2. Comment Out Line 15 to disable cuda.  
3. In Line 33, set BLAS to be open. (or you can use atlas. ) 
<pre>
BLAS:= open
</pre>
4. In Line 65, add **/usr/lib64/** to **LIBRARY\_DIRS**.   
<pre>
LIBRARY_DIRS := $(PYTHON\_LIB) /usr/local/lib /usr/lib /usr/lib64
</pre>
5. make
<pre>
make all
</pre>
##Problem 2
Maybe you will meet these problems.
<pre>
../lib/libcaffe.so: undefined reference to `cblas_sgemv'
{'fraction_non_alphanumeric': 0.10627450980392157, 'fraction_numerical': 0.02196078431372549, 'mean_word_length': 4.264189886480908, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6272188', 'n_tokens_mistral': 1850, 'n_tokens_neox': 1701, 'n_words': 585}