Skip to content

Commit

Permalink
stable version with cudnn7
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroki11x committed Aug 17, 2017
2 parents c80b1e8 + 5c1efbb commit fd900d6
Show file tree
Hide file tree
Showing 45 changed files with 1,104 additions and 207 deletions.
123 changes: 103 additions & 20 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Installation

See http://caffe.berkeleyvision.org/installation.html for the latest
Expand All @@ -14,27 +15,109 @@ $ git clone https://github.com/NVIDIA/caffe
```


2.
2.

```bash
$ cd caffe
$ mkdir build
Edit ~/.bashrc


```diff
+ export LIBRARY_PATH=${GFLAGS_DIR}/lib:${LIBRARY_PATH}
+ export LD_LIBRARY_PATH=${GFLAGS_DIR}/lib:${LD_LIBRARY_PATH}
```

modify cmake/Cuda.cmake
modify Makefile
modify cmake/Modules/FindAtlas.cmake
3.

```bash
$ cd build
$ CMAKE_PREFIX_PATH=$NV_CAFFE_HOME/share \
cmake \
-DCMAKE_INSTALL_PREFIX=$NV_CAFFE_HOME \
-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_HOME\ #required >=8.0
-DBLAS=$Atlas_LAPACK_LIBRARY \
-DCUDNN_LIBRARY=$CUDNN_LIBRARY \ #required >=6.0
-DCUDNN_INCLUDE=$CUDNN_INCLUDE \ #required >=6.0
..

$ make all -j 8
$
Edit some Cmake Files

```diff
--- a/cmake/Cuda.cmake
+++ b/cmake/Cuda.cmake
@@ -251,6 +251,9 @@ if(USE_CUDNN)
endif()
endif()

+list(APPEND CUDA_NVCC_FLAGS "--pre-include $ENV{CUDNN6_HOME}/include/cudnn.h")
+include_directories(BEFORE "$ENV{CUDNN6_HOME}/include")
+
if(UNIX OR APPLE)
list(APPEND CUDA_NVCC_FLAGS -std=c++11;-Xcompiler;-fPIC)
endif()
```

```diff
diff --git a/cmake/Modules/FindAtlas.cmake b/cmake/Modules/FindAtlas.cmake
index 6e15643..e83fbeb 100644
--- a/cmake/Modules/FindAtlas.cmake
+++ b/cmake/Modules/FindAtlas.cmake
@@ -28,7 +28,7 @@ find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES clapack.h PATHS ${Atlas_INCLUDE_SEARCH

find_library(Atlas_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS})
find_library(Atlas_BLAS_LIBRARY NAMES atlas_r atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
-find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
+find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r lapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})

set(LOOKED_FOR
Atlas_CBLAS_INCLUDE_DIR
diff --git a/cmake/Modules/FindNCCL.cmake b/cmake/Modules/FindNCCL.cmake
index 1f7d97c..73f816c 100644
--- a/cmake/Modules/FindNCCL.cmake
+++ b/cmake/Modules/FindNCCL.cmake
@@ -20,6 +20,7 @@ find_package_handle_standard_args(NCCL DEFAULT_MSG NCCL_INCLUDE_DIR NCCL_LIBRARY

if(NCCL_FOUND)
message(STATUS "Found NCCL (include: ${NCCL_INCLUDE_DIR}, library: ${NCCL_LIBRARY})")
+ include_directories(${NCCL_INCLUDE_DIR})
mark_as_advanced(NCCL_INCLUDE_DIR NCCL_LIBRARY)
endif()
```

```diff
diff --git a/cmake/Modules/FindNVML.cmake b/cmake/Modules/FindNVML.cmake
index 8747ab3..2a8b3e7 100644
--- a/cmake/Modules/FindNVML.cmake
+++ b/cmake/Modules/FindNVML.cmake
@@ -14,8 +14,16 @@ find_path(NVML_INCLUDE_DIR NAMES nvml.h
PATHS ${CUDA_INCLUDE_DIRS} ${NVML_ROOT_DIR}/include
)

+set(MLPATH "/usr/lib64/nvidia")
+
find_library(NVML_LIBRARY nvidia-ml PATHS ${MLPATH} ${NVML_ROOT_DIR}/lib ${NVML_ROOT_DIR}/lib64)

+
+message(STATUS "CUDA_INCLUDE_DIRS: ${CUDA_INCLUDE_DIRS}")
+message(STATUS "NVML_INCLUDE_DIR: ${NVML_INCLUDE_DIR}")
+message(STATUS "NVML_LIBRARY: ${NVML_LIBRARY}")
+
+
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NVML DEFAULT_MSG NVML_INCLUDE_DIR NVML_LIBRARY)
```

4.
Then you can do CMAKE

```
cmake -DCMAKE_INSTALL_PREFIX=${CAFFE_0.16_HOME} -DCUDA_TOOLKIT_ROOT_DIR=${CUDA8_HOME} ..
```

console output seems like


```
-- Found gflags (include: /usr/include, library: /usr/lib64/libgflags.so)
```

after that ,you should do make command

```
$ make all -j 64
$ make install -j 64
```

However, if you check library dependency by using ldd command

```
$ldd ${CAFFE_HOME}/build/tools/caffe
libgflags.so.2.2 => ${GFLAGS_DIR}libs//libgflags.so.2.2 (0x0000XXXXXXXXXX)
```
10 changes: 5 additions & 5 deletions examples/imagenet/create_imagenet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Create the imagenet lmdb inputs
# N.B. set the path to the imagenet train + val data dirs

EXAMPLE=examples/imagenet
DATA=data/ilsvrc12
TOOLS=build/tools
EXAMPLE=/mnt/nas100/share/data/imagenet/caffe_tool_dir
DATA=/mnt/nas100/share/data/imagenet/caffe_tool_dir/txt_dir
TOOLS=/home/hiroki11x/dl/NV-Caffe/build/tools

TRAIN_DATA_ROOT=/path/to/imagenet/train/
VAL_DATA_ROOT=/path/to/imagenet/val/
TRAIN_DATA_ROOT=/mnt/nas100/share/data/imagenet/train/
VAL_DATA_ROOT=/mnt/nas100/share/data/imagenet/val/

# Set RESIZE=true to resize the images to 256x256. Leave as false if images have
# already been resized using another tool.
Expand Down
3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
make all -j 64
make test -j 64
make runtest -j 64
15 changes: 15 additions & 0 deletions models/bvlc_alexnet/train_val_fp16.prototxt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ layer {
transform_param {
mirror: true
crop_size: 227
<<<<<<< HEAD
mean_file: "/home/hiroki11x/ImageNet/imagenet_mean.binaryproto"
}
data_param {
source: "/home/hiroki11x/ImageNet/ilsvrc12_train_lmdb"
=======
mean_file: "/mnt/nas101/hiroki11x/imagenet_mean.binaryproto"
}
data_param {
source: "/mnt/nas101/hiroki11x/ilsvrc12_train_lmdb"
>>>>>>> 5c1efbba51c185a619be77a215179bf2b04d9e7a
batch_size: 256
# batch_size: 1024 # DGX1
backend: LMDB
Expand All @@ -31,11 +38,19 @@ layer {
transform_param {
mirror: false
crop_size: 227
<<<<<<< HEAD
mean_file: "/home/hiroki11x/ImageNet/imagenet_mean.binaryproto"
}
data_param {
source: "/home/hiroki11x/ImageNet/ilsvrc12_val_lmdb"
batch_size: 10
=======
mean_file: "/mnt/nas101/hiroki11x/imagenet_mean.binaryproto"
}
data_param {
source: "/mnt/nas101/hiroki11x/ilsvrc12_val_lmdb"
batch_size: 32
>>>>>>> 5c1efbba51c185a619be77a215179bf2b04d9e7a
# batch_size: 256 # DGx1
backend: LMDB
}
Expand Down
8 changes: 7 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ PREFIX_PATH=$PREFIX_PATH:$LOCAL/$s
done


for file in `git grep -l '"/home/hiroki11x/env/local/cuda/include/cudnn.h"'`; do
sed -i -e \
's@"/home/hiroki11x/env/local/cuda/include/cudnn.h"@<cudnn.h>@g' \
"$file"
done

CMAKE_PREFIX_PATH=$PYTHON_INCLUDE:$PYTHON_LIB:$HDF5_HL_LIBRARIES:$PREFIX_PATH cmake \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-DCMAKE_INSTALL_PREFIX=/home/hiroki11x/dl/nvcaffe \
-DCMAKE_INSTALL_PREFIX=/home/hiroki11x/dl/nvcaffe/local \
-DUSE_NCCL=ON \
-DAtlas_LAPACK_LIBRARY=/home/hiroki11x/env/local/ATLAS \
-DUSE_LEVELDB=OFF \
.. | tee configure.log

Expand Down
65 changes: 0 additions & 65 deletions share/Caffe/CaffeConfig.cmake

This file was deleted.

30 changes: 0 additions & 30 deletions share/Caffe/CaffeTargets-release.cmake

This file was deleted.

86 changes: 0 additions & 86 deletions share/Caffe/CaffeTargets.cmake

This file was deleted.

Loading

0 comments on commit fd900d6

Please sign in to comment.