Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SeetaResearch
/
Dragon
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4f4ac2ef
authored
Jun 03, 2018
by
Ting PAN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compiling errors at CPU && OSX support
1 parent
79a52211
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
39 deletions
Dragon/CMakeLists.txt
Dragon/include/core/common.h
Dragon/include/core/tensor.h
Dragon/include/utils/cuda_device.h
Dragon/modules/cxx/CMakeLists.txt
Dragon/modules/python/CMakeLists.txt
Dragon/modules/python/py_cuda.h
Dragon/python/setup.py
Dragon/src/core/mixedmem.cc
Dragon/CMakeLists.txt
View file @
4f4ac2e
...
@@ -22,11 +22,11 @@ option(WITH_CUDA_FP16 "Set ON to use FP16" ON)
...
@@ -22,11 +22,11 @@ option(WITH_CUDA_FP16 "Set ON to use FP16" ON)
# Set your 3rdparty
# Set your 3rdparty
set
(
3RDPARTY_DIR
${
PROJECT_SOURCE_DIR
}
/../3rdparty
)
set
(
3RDPARTY_DIR
${
PROJECT_SOURCE_DIR
}
/../3rdparty
)
#
s
et your python "interpreter" if necessary
#
S
et your python "interpreter" if necessary
# if not, a default interpreter will be used
# if not, a default interpreter will be used
# here, provide several examples:
# here, provide several examples:
# set(PYTHON_EXECUTABLE /usr/bin/python) # Linux
, OS
# set(PYTHON_EXECUTABLE /usr/bin/python) # Linux
& OSX, Builtin Python
# set(PYTHON_EXECUTABLE /X/anaconda/bin/python) # Linux, Anaconda
# set(PYTHON_EXECUTABLE /X/anaconda/bin/python) # Linux
& OSX
, Anaconda
# set(PYTHON_EXECUTABLE X:/Anaconda/python) # Win, Anaconda
# set(PYTHON_EXECUTABLE X:/Anaconda/python) # Win, Anaconda
# Set CUDA compiling architecture
# Set CUDA compiling architecture
...
@@ -37,9 +37,10 @@ set(CUDA_ARCH -gencode arch=compute_30,code=sm_30
...
@@ -37,9 +37,10 @@ set(CUDA_ARCH -gencode arch=compute_30,code=sm_30
-gencode arch=compute_60,code=sm_60
-gencode arch=compute_60,code=sm_60
-gencode arch=compute_70,code=sm_70
)
-gencode arch=compute_70,code=sm_70
)
# Set CUDNN Library Dir if necessary (Linux Only)
# Set CUDNN Library Dir if necessary (Linux
/OSX
Only)
# For Win, Recommend to use ``3RDPARTY_DIR/lib``
# For Win, Recommend to use ``3RDPARTY_DIR/lib``
set
(
CUDNN_LIBRARY_DIR /usr/local/cuda/lib64
)
set
(
CUDNN_LIBRARY_DIR /usr/local/cuda/lib64
)
# Linux
# set(CUDNN_LIBRARY_DIR /usr/local/cuda/lib) # OSX
# ---------------- User Config ----------------
# ---------------- User Config ----------------
...
@@ -178,7 +179,7 @@ endif()
...
@@ -178,7 +179,7 @@ endif()
if
(
UNIX
)
if
(
UNIX
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-s -fPIC"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-s -fPIC"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-s -w -fPIC -O3 -m64 -std=c++11"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-s -w -fPIC -O3 -m64 -std=c++11"
)
if
(
WITH_OMP
)
if
(
WITH_OMP
AND
(
NOT APPLE
)
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fopenmp"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fopenmp"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fopenmp"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fopenmp"
)
endif
()
endif
()
...
...
Dragon/include/core/common.h
View file @
4f4ac2e
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include <unordered_set>
#include <unordered_set>
#include <algorithm>
#include <algorithm>
#include <mutex>
#include <mutex>
#include <functional>
#include "core/types.h"
#include "core/types.h"
#include "protos/dragon.pb.h"
#include "protos/dragon.pb.h"
...
...
Dragon/include/core/tensor.h
View file @
4f4ac2e
...
@@ -12,8 +12,6 @@
...
@@ -12,8 +12,6 @@
#ifndef DRAGON_CORE_TENSOR_H_
#ifndef DRAGON_CORE_TENSOR_H_
#define DRAONG_CORE_TENSOR_H_
#define DRAONG_CORE_TENSOR_H_
#include <vector>
#include "core/common.h"
#include "core/common.h"
#include "core/mixedmem.h"
#include "core/mixedmem.h"
...
...
Dragon/include/utils/cuda_device.h
View file @
4f4ac2e
...
@@ -13,20 +13,22 @@
...
@@ -13,20 +13,22 @@
#define DRAGON_UTILS_CUDA_DEVICE_H_
#define DRAGON_UTILS_CUDA_DEVICE_H_
#ifdef WITH_CUDA
#ifdef WITH_CUDA
#include <cuda_runtime.h>
#include <cuda_runtime.h>
#include <cublas.h>
#include <cublas.h>
#include <curand.h>
#include <curand.h>
#include <cuda.h>
#include <cuda.h>
#endif
#ifdef WITH_MPI_NCCL
#ifdef WITH_MPI_NCCL
#include <nccl.h>
#include <nccl.h>
#endif
// WITH_MPI_NCCL
#endif
#include "core/common.h"
#include "core/common.h"
namespace
dragon
{
namespace
dragon
{
#ifdef WITH_CUDA
static
const
int
CUDA_NUM_THREADS
=
1024
;
static
const
int
CUDA_NUM_THREADS
=
1024
;
// We do have a server with 10 GPUs :-)
// We do have a server with 10 GPUs :-)
#define MAX_GPUS 10
#define MAX_GPUS 10
...
...
Dragon/modules/cxx/CMakeLists.txt
View file @
4f4ac2e
...
@@ -3,7 +3,7 @@ message(STATUS "Found CXX Module: ${CMAKE_CURRENT_LIST_DIR}")
...
@@ -3,7 +3,7 @@ message(STATUS "Found CXX Module: ${CMAKE_CURRENT_LIST_DIR}")
FILE
(
GLOB_RECURSE MODULE_FILES *.h *.hpp *.c *.cpp *.cu *.cc
)
FILE
(
GLOB_RECURSE MODULE_FILES *.h *.hpp *.c *.cpp *.cu *.cc
)
FILE
(
GLOB_RECURSE SRC_FILES ../../src/*.c ../../src/*.cpp ../../src/*.cu ../../src/*.cc
)
FILE
(
GLOB_RECURSE SRC_FILES ../../src/*.c ../../src/*.cpp ../../src/*.cu ../../src/*.cc
)
# ---[
complier
# ---[
Target
if
(
WITH_CUDA
)
if
(
WITH_CUDA
)
CUDA_ADD_LIBRARY
(
${
PROJECT_NAME
}
_cxx SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
CUDA_ADD_LIBRARY
(
${
PROJECT_NAME
}
_cxx SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx
${
CUDA_LIBRARIES
}
${
CUDA_cublas_LIBRARY
}
${
CUDA_curand_LIBRARY
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx
${
CUDA_LIBRARIES
}
${
CUDA_cublas_LIBRARY
}
${
CUDA_curand_LIBRARY
}
)
...
@@ -11,14 +11,13 @@ else ()
...
@@ -11,14 +11,13 @@ else ()
ADD_LIBRARY
(
${
PROJECT_NAME
}
_cxx SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
ADD_LIBRARY
(
${
PROJECT_NAME
}
_cxx SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
endif
()
endif
()
# ---[ Linker(Basics)
# ---[ link basics
FILE
(
GLOB targets
${
3RDPARTY_LIBS
}
/*.so
${
3RDPARTY_LIBS
}
/*.lib
)
FILE
(
GLOB targets
${
3RDPARTY_LIBS
}
/*.so
${
3RDPARTY_LIBS
}
/*.lib
)
foreach
(
target
${
targets
}
)
foreach
(
target
${
targets
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx
${
target
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx
${
target
}
)
endforeach
()
endforeach
()
# ---[
link optional libs
# ---[
Linker(OptionalLibs)
if
(
UNIX AND WITH_CUDNN
)
if
(
UNIX AND WITH_CUDNN
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx cudnn
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx cudnn
)
endif
()
endif
()
...
@@ -29,15 +28,15 @@ if (UNIX AND WITH_MPI_NCCL)
...
@@ -29,15 +28,15 @@ if (UNIX AND WITH_MPI_NCCL)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx nccl
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx nccl
)
endif
()
endif
()
# ---[
link platforms
# ---[
Linker(Platforms)
if
(
UNIX
)
if
(
UNIX
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx protobuf pthread
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx protobuf pthread
)
endif
()
endif
()
if
(
WIN32
)
if
(
WIN32
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx
shlwapi.lib
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_cxx shlwapi.lib
)
endif
()
endif
()
set_target_properties
(
${
PROJECT_NAME
}
_cxx PROPERTIES OUTPUT_NAME dragon_cxx
)
SET_TARGET_PROPERTIES
(
${
PROJECT_NAME
}
_cxx PROPERTIES OUTPUT_NAME dragon_cxx
)
# ---[ install
# ---[ Install
install
(
TARGETS
${
PROJECT_NAME
}
_cxx DESTINATION
${
PROJECT_BINARY_DIR
}
/../lib
)
INSTALL
(
TARGETS
${
PROJECT_NAME
}
_cxx DESTINATION
${
PROJECT_BINARY_DIR
}
/../lib
)
\ No newline at end of file
\ No newline at end of file
Dragon/modules/python/CMakeLists.txt
View file @
4f4ac2e
...
@@ -7,7 +7,7 @@ endif()
...
@@ -7,7 +7,7 @@ endif()
FILE
(
GLOB_RECURSE MODULE_FILES *.h *.hpp *.c *.cpp *.cu *.cc
)
FILE
(
GLOB_RECURSE MODULE_FILES *.h *.hpp *.c *.cpp *.cu *.cc
)
FILE
(
GLOB_RECURSE SRC_FILES ../../src/*.c ../../src/*.cpp ../../src/*.cu ../../src/*.cc
)
FILE
(
GLOB_RECURSE SRC_FILES ../../src/*.c ../../src/*.cpp ../../src/*.cu ../../src/*.cc
)
# ---[
complier
# ---[
Target
if
(
WITH_CUDA
)
if
(
WITH_CUDA
)
CUDA_ADD_LIBRARY
(
${
PROJECT_NAME
}
_python SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
CUDA_ADD_LIBRARY
(
${
PROJECT_NAME
}
_python SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python
${
CUDA_LIBRARIES
}
${
CUDA_cublas_LIBRARY
}
${
CUDA_curand_LIBRARY
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python
${
CUDA_LIBRARIES
}
${
CUDA_cublas_LIBRARY
}
${
CUDA_curand_LIBRARY
}
)
...
@@ -15,14 +15,13 @@ else ()
...
@@ -15,14 +15,13 @@ else ()
ADD_LIBRARY
(
${
PROJECT_NAME
}
_python SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
ADD_LIBRARY
(
${
PROJECT_NAME
}
_python SHARED
${
MODULE_FILES
}
${
SRC_FILES
}
)
endif
()
endif
()
# ---[ Linker(Basics)
# ---[ link basics
FILE
(
GLOB targets
${
3RDPARTY_LIBS
}
/*.so
${
3RDPARTY_LIBS
}
/*.lib
)
FILE
(
GLOB targets
${
3RDPARTY_LIBS
}
/*.so
${
3RDPARTY_LIBS
}
/*.lib
)
foreach
(
target
${
targets
}
)
foreach
(
target
${
targets
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python
${
target
}
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python
${
target
}
)
endforeach
()
endforeach
()
# ---[
link optional libs
# ---[
Linker(OptionalLibs)
if
(
UNIX AND WITH_CUDNN
)
if
(
UNIX AND WITH_CUDNN
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python cudnn
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python cudnn
)
endif
()
endif
()
...
@@ -33,15 +32,19 @@ if (UNIX AND WITH_MPI_NCCL)
...
@@ -33,15 +32,19 @@ if (UNIX AND WITH_MPI_NCCL)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python nccl
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python nccl
)
endif
()
endif
()
# ---[
link platforms
# ---[
Linker(Platforms)
if
(
UNIX
)
if
(
UNIX
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python protobuf pthread
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python protobuf pthread
)
endif
()
endif
()
if
(
WIN32
)
if
(
WIN32
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python shlwapi.lib
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python shlwapi.lib
)
TARGET_LINK_LIBRARIES
(
${
PROJECT_NAME
}
_python
${
PYTHON_LIBRARIES
}
)
endif
()
if
(
APPLE
)
SET_TARGET_PROPERTIES
(
${
PROJECT_NAME
}
_python PROPERTIES LINK_FLAGS
"-undefined dynamic_lookup"
)
endif
()
endif
()
set_target_properties
(
${
PROJECT_NAME
}
_python PROPERTIES OUTPUT_NAME dragon
)
SET_TARGET_PROPERTIES
(
${
PROJECT_NAME
}
_python PROPERTIES OUTPUT_NAME dragon
)
# ---[ install
# ---[ Install
install
(
TARGETS
${
PROJECT_NAME
}
_python DESTINATION
${
PROJECT_BINARY_DIR
}
/../lib
)
INSTALL
(
TARGETS
${
PROJECT_NAME
}
_python DESTINATION
${
PROJECT_BINARY_DIR
}
/../lib
)
\ No newline at end of file
\ No newline at end of file
Dragon/modules/python/py_cuda.h
View file @
4f4ac2e
...
@@ -14,17 +14,15 @@
...
@@ -14,17 +14,15 @@
#include "dragon.h"
#include "dragon.h"
#ifdef WITH_CUDA
inline
PyObject
*
IsCUDADriverSufficientCC
(
PyObject
*
self
,
PyObject
*
args
)
{
inline
PyObject
*
IsCUDADriverSufficientCC
(
PyObject
*
self
,
PyObject
*
args
)
{
#ifdef WITH_CUDA
int
count
;
int
count
;
cudaError_t
err
=
cudaGetDeviceCount
(
&
count
);
cudaError_t
err
=
cudaGetDeviceCount
(
&
count
);
if
(
err
==
cudaErrorInsufficientDriver
)
return
PyBool_FromLong
(
0
);
if
(
err
==
cudaErrorInsufficientDriver
)
return
PyBool_FromLong
(
0
);
return
PyBool_FromLong
(
1
);
return
PyBool_FromLong
(
1
);
}
#else
#else
CUDA_NOT_COMPILED
;
CUDA_NOT_COMPILED
;
#endif
#endif
}
#endif // DRAGON_PYTHON_PY_MPI_H_
#endif // DRAGON_PYTHON_PY_MPI_H_
\ No newline at end of file
Dragon/python/setup.py
View file @
4f4ac2e
...
@@ -14,13 +14,17 @@ def find_packages(root_dir):
...
@@ -14,13 +14,17 @@ def find_packages(root_dir):
if
filename
==
'__init__.py'
:
if
filename
==
'__init__.py'
:
packages
.
append
(
root_dir
)
packages
.
append
(
root_dir
)
def
find_modules
():
def
find_modules
():
dragon_c_lib_win32
=
'../lib/dragon.dll'
dragon_c_lib_win32
=
'../lib/dragon.dll'
dragon_c_lib_other
=
'../lib/libdragon.so'
dragon_c_lib_linux
=
'../lib/libdragon.so'
dragon_c_lib_darwin
=
'../lib/libdragon.dylib'
if
os
.
path
.
exists
(
dragon_c_lib_win32
):
if
os
.
path
.
exists
(
dragon_c_lib_win32
):
shutil
.
copy
(
dragon_c_lib_win32
,
'dragon/libdragon.pyd'
)
shutil
.
copy
(
dragon_c_lib_win32
,
'dragon/libdragon.pyd'
)
elif
os
.
path
.
exists
(
dragon_c_lib_other
):
elif
os
.
path
.
exists
(
dragon_c_lib_linux
):
shutil
.
copy
(
dragon_c_lib_other
,
'dragon/libdragon.so'
)
shutil
.
copy
(
dragon_c_lib_linux
,
'dragon/libdragon.so'
)
elif
os
.
path
.
exists
(
dragon_c_lib_darwin
):
shutil
.
copy
(
dragon_c_lib_darwin
,
'dragon/libdragon.so'
)
else
:
else
:
print
(
'ERROR: Unable to find modules. built Dragon using CMake.'
)
print
(
'ERROR: Unable to find modules. built Dragon using CMake.'
)
sys
.
exit
()
sys
.
exit
()
...
@@ -32,15 +36,17 @@ def find_resources():
...
@@ -32,15 +36,17 @@ def find_resources():
others
=
[]
others
=
[]
return
c_lib
+
protos
+
others
return
c_lib
+
protos
+
others
find_packages
(
'dragon'
)
find_packages
(
'dragon'
)
find_modules
()
find_modules
()
setup
(
name
=
'dragon'
,
setup
(
name
=
'dragon'
,
version
=
'0.2.2.
2
'
,
version
=
'0.2.2.
3
'
,
description
=
'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework'
,
description
=
'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework'
,
url
=
'https://github.com/seetaresearch/Dragon'
,
url
=
'https://github.com/seetaresearch/Dragon'
,
author
=
'Ting Pan'
,
author
=
'Ting Pan'
,
license
=
'BSD 2-Clause'
,
license
=
'BSD 2-Clause'
,
packages
=
packages
,
packages
=
packages
,
package_dir
=
{
'dragon'
:
'dragon'
},
package_dir
=
{
'dragon'
:
'dragon'
},
package_data
=
{
'dragon'
:
find_resources
()})
package_data
=
{
'dragon'
:
find_resources
()})
\ No newline at end of file
Dragon/src/core/mixedmem.cc
View file @
4f4ac2e
...
@@ -164,7 +164,9 @@ const Map<string, string> MixedMemory::info() const {
...
@@ -164,7 +164,9 @@ const Map<string, string> MixedMemory::info() const {
}
}
s2s
[
"mem_at"
]
=
_state_
;
s2s
[
"mem_at"
]
=
_state_
;
if
(
cpu_ptr_
)
s2s
[
"CPU"
]
=
"0"
;
if
(
cpu_ptr_
)
s2s
[
"CPU"
]
=
"0"
;
#ifdef WITH_CUDA
if
(
cuda_ptr_
)
s2s
[
"CUDA"
]
=
dragon_cast
<
string
,
int
>
(
CUDA_POINTER_DEVICE
(
cuda_ptr_
));
if
(
cuda_ptr_
)
s2s
[
"CUDA"
]
=
dragon_cast
<
string
,
int
>
(
CUDA_POINTER_DEVICE
(
cuda_ptr_
));
#endif
return
s2s
;
return
s2s
;
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment