Skip to content

Commit

Permalink
merge from 8.x to master
Browse files Browse the repository at this point in the history
  • Loading branch information
hughperkins committed Aug 28, 2015
2 parents 7a17767 + 5dacaa8 commit 44a4ef3
Show file tree
Hide file tree
Showing 440 changed files with 13,107 additions and 11,090 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.lo
*.o
*.obj
foo.dat

# Precompiled Headers
*.gch
Expand Down
61 changes: 47 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,25 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

OPTION(LIBJPEG_AVAILABLE "Allows native loading of jpegs, via manifest file." ON)
OPTION(DEV_RUN_COG "DeepCL maintainers only, otherwise set to 'OFF'." OFF)
OPTION(PROTOTYPING "Only for devs." OFF)
mark_as_advanced( FORCE PROTOTYPING )
OPTION(LIBPNGPP_AVAILABLE "Some toys/samples only." OFF)
mark_as_advanced(FORCE LIBPNGPP_AVAILABLE)
#OPTION(BUILD_PYTHON_WRAPPERS "Build Python wrappers. Needs Python." ON)
OPTION(BUILD_JPEG_SUPPORT "Allows native loading of jpegs, via manifest file." ON)
OPTION(BUILD_INTERNAL_LUA "If using from Lua, set to 'OFF'" ON)
OPTION(MAINTAINER_OPTIONS "Show maintainer options" OFF)

if(MAINTAINER_OPTIONS)
OPTION(BUILD_PYTHON_WRAPPERS "Build python wrappers. Maintainers only." OFF.)
OPTION(DEV_RUN_COG "DeepCL maintainers only, otherwise set to 'OFF'." OFF)
OPTION(PROTOTYPING "Only for devs." OFF)
# mark_as_advanced( FORCE PROTOTYPING )
OPTION(LIBPNGPP_AVAILABLE "Some toys/samples only." OFF)
# mark_as_advanced(FORCE LIBPNGPP_AVAILABLE)
else()
unset(DEV_RUN_COG CACHE)
unset(DEV_RUN_CYTHON CACHE)
unset(BUILD_PYTHON_WRAPPERS CACHE)
unset(LIBPNGPP_AVAILABLE CACHE)
unset(PROTOTYPING CACHE)
endif()

IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX
Expand All @@ -27,9 +40,10 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# remove old flags from the cache:
unset(LIBJPEG_AVAILABLE CACHE)
unset(PROVIDE_LUA_ENGINE CACHE)
unset(BUILD_PYSWIG_WRAPPERS CACHE)
unset(BUILD_LUA_WRAPPERS CACHE)
unset(BUILD_PYTHON_WRAPPERS CACHE)
unset(RUN_COG CACHE)
unset(RUN_SWIG CACHE)
unset(DEV_RUN_SWIG CACHE)
Expand All @@ -42,7 +56,7 @@ unset(LUA_INCLUDE_DIR CACHE)

# SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/dist" CACHE STRING "Installation directory." FORCE)

SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

INCLUDE("${CMAKE_MODULE_PATH}/build_EasyCL.cmake")
INCLUDE_DIRECTORIES(${EASYCL_INCLUDE_DIRS})
Expand All @@ -57,15 +71,14 @@ include_directories( src )
include_directories( qlearning )

if( ON_LINUX )
# target_link_libraries(EasyCL dl)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")
endif()

if( ON_WINDOWS)
link_libraries(winmm) # needed for timeGetTime
endif()

set(dirs activate batch clmath conv dropout fc forcebackprop input layer loaders
set(dirs clblas activate batch clmath conv dropout fc forcebackprop input layer loaders
loss net netdef normalize patches pooling trainers util weights qlearning
)
foreach(dir ${dirs})
Expand All @@ -75,6 +88,7 @@ foreach(dir ${dirs})
set( deepcl_sources ${deepcl_sources} src/${dir}/${source})
endforeach()
endforeach()
set(deepcl_sources ${deepcl_sources} src/DeepCL.cpp src/CppRuntimeBoundary.cpp)
#message("deepcl_sources ${deepcl_sources}")

#find_package(Lua51)
Expand Down Expand Up @@ -141,23 +155,25 @@ if( LIBPNGPP_AVAILABLE)
target_link_libraries(deepcl_unittests ${PNG_LIBRARY})
endif(LIBPNGPP_AVAILABLE)

link_libraries(DeepCL)
#link_libraries(DeepCL)

if(DEV_RUN_COG)
foreach( dir ${dirs} main)
set(cog_dirs ${cog_dirs} ${CMAKE_CURRENT_SOURCE_DIR}/src/${dir}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/${dir}/*.h)
endforeach()
add_custom_target(
cog
python ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cogapp/cog.py -q -I ${CMAKE_CURRENT_SOURCE_DIR}/cog-batteries -r ${cog_dirs} ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/*.h ${CMAKE_CURRENT_SOURCE_DIR}/prototyping/*.cpp
python ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cogapp/cog.py -q -I ${CMAKE_CURRENT_SOURCE_DIR}/cog-batteries -r ${cog_dirs} ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/*.h ${CMAKE_CURRENT_SOURCE_DIR}/prototyping/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies( DeepCL cog )
endif(DEV_RUN_COG)

#ADD_DEPENDENCIES(DeepCL clBLAS)

set( UNITTEST_SOURCES test/testupdateweights.cpp test/testforward.cpp test/testfilehelper.cpp
set( UNITTEST_SOURCES test/testClBlas.cpp
test/testDeepCL.cpp
test/testupdateweights.cpp test/testforward.cpp test/testfilehelper.cpp
test/testsimpleconvolvenet.cpp test/testlogicaloperators.cpp
test/testbackward.cpp test/testsinglebatch.cpp
test/testpoolingforward.cpp test/testpoolingbackward.cpp test/testNorbLoader.cpp
Expand All @@ -173,6 +189,7 @@ set( UNITTEST_SOURCES test/testupdateweights.cpp test/testforward.cpp test/testf
if(LIBJPEG_AVAILABLE)
set(UNITTEST_SOURCES ${UNITTEST_SOURCES} test/testjpeghelper.cpp)
add_executable( mnist-to-jpegs test/mnist-to-jpegs.cpp src/util/stringhelper.cpp src/loaders/MnistLoader.cpp )
target_link_libraries(mnist-to-jpegs DeepCL)
endif(LIBJPEG_AVAILABLE)

add_executable( deepcl_train src/main/train.cpp src/util/stringhelper.cpp )
Expand All @@ -183,13 +200,21 @@ add_executable( prepare-norb test/prepare-norb.cpp src/util/stringhelper.cpp )
add_executable( mnist-to-floats test/mnist-to-floats.cpp src/util/stringhelper.cpp )
add_executable( mnist-to-pipe test/mnist-to-pipe.cpp src/util/stringhelper.cpp )

foreach(exe deepcl_train deepcl_predict cifar-to-mat prepare-norb mnist-to-floats mnist-to-pipe)
target_link_libraries(${exe} DeepCL)
endforeach()

#target_link_libraries( cifar-to-mat ${LUA_LIBRARIES} )

if( LIBPNGPP_AVAILABLE)
add_definitions(-DPNG_AVAILABLE)
add_executable( testpatchextractor test/testPatchExtractor.cpp src/util/stringhelper.cpp src/patches/PatchExtractor.cpp )
add_executable( testtranslator test/testTranslator.cpp src/util/stringhelper.cpp src/patches/Translator.cpp )
add_executable( testgenericloader test/testGenericLoader.cpp src/util/stringhelper.cpp )

foreach(exe testpatchextractor testtranslator testgenericloader)
target_link_libraries(${exe} DeepCL)
endforeach()
endif(LIBPNGPP_AVAILABLE)

if( ON_LINUX )
Expand All @@ -215,9 +240,17 @@ target_link_libraries( deepcl_unittests DeepCL )
add_executable( testgtestsupp test/testgtestsupp.cpp thirdparty/gtest/gtest_main.cc )
target_link_libraries( testgtestsupp deepcl_gtest )

if(BUILD_PYTHON_WRAPPERS)
add_subdirectory(python)
# add_dependencies(PyDeepCL DeepCL)
# target_link_libraries(PyDeepCL DeepCL)
endif()

INSTALL( DIRECTORY src/ DESTINATION include/deepcl FILES_MATCHING PATTERN *.h )
INSTALL(PROGRAMS src/activate.sh DESTINATION bin)
INSTALL(PROGRAMS src/activate.bat DESTINATION bin)
#INSTALL( DIRECTORY EasyCL/ DESTINATION include/easycl FILES_MATCHING PATTERN *.h )
INSTALL( TARGETS DeepCL deepcl_train deepcl_predict deepcl_unittests
INSTALL( TARGETS DeepCL deepcl_train deepcl_predict deepcl_unittests deepcl_gtest
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib )
Expand Down
2 changes: 1 addition & 1 deletion EasyCL
Submodule EasyCL updated 75 files
+10 −10 CLArray.h
+14 −14 CLArrayFloat.h
+11 −11 CLArrayInt.h
+7 −7 CLFloatWrapper.h
+7 −7 CLFloatWrapperConst.h
+6 −6 CLIntWrapper.h
+42 −42 CLKernel.cpp
+23 −26 CLKernel.h
+2 −2 CLKernel_structs.h
+6 −6 CLUCharWrapper.h
+22 −22 CLWrapper.cpp
+5 −5 CLWrapper.h
+11 −2 CMakeLists.txt
+17 −17 DeviceInfo.cpp
+4 −4 DeviceInfo.h
+69 −26 DevicesInfo.cpp
+9 −5 DevicesInfo.h
+140 −140 EasyCL.cpp
+39 −39 EasyCL.h
+32 −21 README.md
+31 −31 deviceinfo_helper.cpp
+9 −9 deviceinfo_helper.h
+10 −0 easycl_activate.sh
+21 −21 gpuinfo.cpp
+13 −0 mystdint.h
+11 −11 platforminfo_helper.cpp
+3 −3 platforminfo_helper.h
+12 −12 templates/LuaTemplater.cpp
+7 −7 templates/LuaTemplater.h
+28 −22 templates/TemplatedKernel.cpp
+11 −10 templates/TemplatedKernel.h
+6 −6 test/asserts.cpp
+11 −11 test/asserts.h
+6 −6 test/easycl_gtest_supp.h
+26 −26 test/easycl_stringhelper.cpp
+13 −13 test/easycl_stringhelper.h
+14 −14 test/gtest_main.cpp
+4 −4 test/testDeviceInfo.cpp
+46 −46 test/testLuaTemplater.cpp
+2 −2 test/testStructs.cl
+3 −3 test/testStructs.cpp
+39 −39 test/testTemplatedKernel.cpp
+1 −1 test/test_scenario_te42kyfo.cl
+8 −8 test/test_scenario_te42kyfo.cpp
+1 −1 test/testbuildlog.cl
+4 −4 test/testbuildlog.cpp
+9 −9 test/testclarray.cpp
+37 −37 test/testcopybuffer.cpp
+1 −1 test/testdefines.cl
+5 −5 test/testdefines.cpp
+20 −20 test/testdirtywrapper.cpp
+5 −5 test/testeasycl.cl
+36 −36 test/testeasycl.cpp
+2 −2 test/testfloatarray.cl
+19 −19 test/testfloatarray.cpp
+17 −17 test/testfloatwrapper.cpp
+11 −11 test/testfloatwrapperconst.cpp
+1 −1 test/testinout.cl
+10 −10 test/testinout.cpp
+2 −2 test/testintarray.cl
+19 −19 test/testintarray.cpp
+11 −11 test/testintwrapper.cpp
+21 −21 test/testintwrapper_huge.cpp
+14 −14 test/testkernelstore.cpp
+33 −33 test/testlocal.cl
+183 −183 test/testlocal.cpp
+21 −21 test/testnewinstantiations.cpp
+19 −19 test/testprofiling.cpp
+35 −35 test/testscalars.cpp
+13 −13 test/teststatefultimer.cpp
+11 −11 test/testucharwrapper.cpp
+19 −13 util/StatefulTimer.cpp
+15 −3 util/StatefulTimer.h
+26 −26 util/easycl_stringhelper.cpp
+13 −13 util/easycl_stringhelper.h
120 changes: 97 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,57 @@ Multicolumn net also possible, as in [McDnn](http://arxiv.org/pdf/1202.2745.pdf)
- obtained 99.5% test accuracy on MNIST, using `netdef=rt2-8c5z-relu-mp2-16c5z-relu-mp3-150n-tanh-10n numepochs=20 multinet=6 learningrate=0.002`
- epoch time 99.8 seconds, using an Amazon GPU instance, ie half an NVidia GRID K520 GPU (since we are learning 6 nets in parallel, so 16.6seconds per epoch per net)

# Releases
# Installation

* Stable: here
* Unstable/dev: please see [8.x](https://github.com/hughperkins/DeepCL/tree/8.x)
## Native library installation

Unstable/dev is working on adding im2col, which promises faster convolution for larger layers, ie layers 1 and 2 in [Soumith's benchmarks](https://github.com/soumith/convnet-benchmarks)
This section installs the native libraries, and the command-line tools. You always need to do this part, even if you will use the Python wrappers.

# To install
### Windows

## Python
#### Pre-requisites:

* For python, please use [Python API](python/README.md), or use [pip](https://pypi.python.org/pypi/DeepCL)
* OpenCL-enabled GPU or APU, along with appropriate OpenCL driver installed
* Tested using Windows 7

## Commandline tools, and c++ libraries
#### Procedure:

### Windows
* Download latest binary zip file from http://deepcl.hughperkins.com/Downloads/
* unzip it, which creates the `dist` folder
* To use it:
* open a cmd
* run `call dist\bin\activate.bat` (adjusting the path appropriately for wherever you downloaded deepcl binaries to)
* now, eg try `deepcl_unittests`

Note that you need to "activate" the installation each time you open a new cmd prompt (or you could add appropriate environment variables permanently, using Control Panel | System | Advanced System Settings | Environment Variables)

### Linux

#### Pre-requisites:

* OpenCL-enabled GPU or APU, along with appropriate OpenCL driver installed (can check by running `clinfo`, which should show your desired GPU device)
* Tested using Ubuntu 14.04 32-bit/64-bit

#### Procedure:

Pre-built binaries are available for Windows. In order to use them you need:
* An OpenCL driver for your GPU
* A recent release with Windows binaries is [v5.5.0](https://github.com/hughperkins/DeepCL/releases/tag/v5.5.0)
* Download latest tar file from http://deepcl.hughperkins.com/Downloads/
* untar it, which creates the `dist` sub-folder
* in a bash prompt, run `source dist\bin\activate.sh` (adjust the path appropriate for wherever you untarred the binaries tar file to)
* test by doing, from the same bash prompt, eg `deepcl_unittests`

### linux
Note that you need to "activate" the installation each time you open a new bash prompt (or you can call activate.sh from your `.bashrc` file)

Pre-build binaries are available for linux. In order to use them you need:
* An OpenCL driver for your GPU
* A recent release with linux binaries is [v5.5.0](https://github.com/hughperkins/DeepCL/releases/tag/v5.5.0)
## Python wrappers

If the binaries dont work on your distribution, please [build from source](doc/Build.md)
* make sure you already installed the native library, and "activate"d it, by doing `call dist\bin\activate.bat`, or `source dist/bin/activate.sh`
* run `pip install --pre DeepCL`
* test by doing `python -c "import PyDeepCL; cl = PyDeepCL.DeepCL()"`

## To build from source

Building from source is only needed if installing from binaries doesn't work for your configuration, or if you want to modify DeepCL.

See [Build.md](doc/Build.md)

## What if it doesn't run?

Expand Down Expand Up @@ -137,11 +160,8 @@ Related projects
================

* [kgsgo-dataset-preprocessor](https://github.com/hughperkins/kgsgo-dataset-preprocessor) Dataset based on kgsgo games; 33 million data points

Credits
=======

* Tambet Matilsen has provided excellent suggestions and feedback on which functionalities to prioritize, and on how to make the website somewhat presentable
* [cltorch](https://github.com/hughperkins/cltorch)
* [clnn](https://github.com/hughperkins/clnn)

License
=======
Expand All @@ -151,12 +171,66 @@ License
Recent changes
==============

* Aug 28th:
* installation of 8.x from binaries on Windows works now, by doing, eg on 32-bit Windows 7, and assuming you already activated an appropriate python environment (assumes 7-zip is installed, in default location, otherwise do the unzip by hand):
```
powershell Set-ExecutionPolicy unrestricted
rem following command is like `wget` in linux:
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('http://deepcl.hughperkins.com/Downloads/deepcl-win32-v8.0.0rc8.zip', 'deepcl-win32-v8.0.0rc8.zip')
rem following command is like `tar -xf` in linux:
"c:\program files\7-Zip\7z.exe" x deepcl-win32-v8.0.0rc8.zip
call dist\bin\activate.bat
pip install --pre DeepCL
python -c "import PyDeepCL; cl = PyDeepCL.DeepCL()"
```
(last line is just to check works ok)
* merged 8.x branch to master, will release first version of 8.x shortly
* Aug 26th: installation of 8.x from binaries on linux works now, by doing, eg on 64-bit Ubuntu 14.04:
```
mkdir 8.0.0rc4
cd 8.0.0rc4
wget http://deepcl.hughperkins.com/Downloads/deepcl-linux64-v8.0.0rc4.tar.bz2
tar -xf deepcl-linux64-v8.0.0rc4.tar.bz2
virtualenv env
source env/bin/activate
source dist/bin/activate.sh
pip install --pre DeepCL
python -c "import PyDeepCL; cl = PyDeepCL.DeepCL()"
```
(last line is just to check works ok)
* Aug 21st-24th:
* 8.x finally builds again on all supported configurations!
* ubuntu 14.04 32-bit Python 2.7
* ubuntu 14.04 32-bit Python 3.4
* ubuntu 14.04 64-bit Python 2.7
* ubuntu 14.04 64-bit Python 3.4
* visual studio 2010 32-bit python 2.7
* visual studio 2010 32-bit python 3.4
* visual studio 2010 64-bit python 2.7
* visual studio 2010 64-bit python 3.4
* Aug 19th-20th:
* Python wrappers now built using a very thin setup.py layer, on top of the standard native DeepCL build
* Aug 18th:
* added BackwardIm2Col layer, which uses im2col for backward propagation
* added BackpropWeightsIm2Col layer, which uses im2col for weight update
* added BackwardAuto layer, which automatically selects fastest Backward layer
* added BackpropWeightsAuto layer, which automatically selects faster weight update layer
* under the covers:
* created ClBlasHelper, to handle Gemm and Gemv
* factorized im2col into Im2Col class
* week up to Aug 17th:
* added forward and backward im2col layer
* forward im2col automatically used during forward propagation, where appropriate
* backwards has yet to be integrated
* under the covers:
* added clBLAS
* migrated the Python build process to use cmake, rather than setup.py (whether this turns out to be good or bad is a bit up in the air for now)
* June 22nd:
* removed lua wrappers
* if you want to use lua with OpenCL, please consider using [cltorch](http://github.com/hughperkins/cltorch) and [clnn](http://github.com/hughperkins/clnn)

To get in contact
=================

There is a mailing list at http://lists.hughperkins.com/listinfo.cgi/deepcl-hughperkins.com for discussions, ideas, or just to say 'hi'. You can also just create issues, in github, in the top right of this page.
Just create an issues, in github, in the top right of this page. Don't worry about whether you think the issue sounds silly or anything. The more feedback the better!

Loading

0 comments on commit 44a4ef3

Please sign in to comment.