Skip to content

Commit

Permalink
Upgrade to CUDA 9.0 and cuDNN 7.0 (deeplearning4j#4129)
Browse files Browse the repository at this point in the history
* Upgrade to CUDA 9.0 and cuDNN 7.0

* Change javacpp-presets back to release version for CUDA
  • Loading branch information
saudet authored and raver119 committed Oct 4, 2017
1 parent 69251fa commit 907d414
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
36 changes: 23 additions & 13 deletions change-cuda-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@

set -e

VALID_VERSIONS=( 7.5 8.0 )
CUDA_75_VERSION="7\.5"
VALID_VERSIONS=( 8.0 9.0 )
CUDA_80_VERSION="8\.0"
CUDA_90_VERSION="9\.0"
CUDNN_60_VERSION="6\.0"
CUDNN_70_VERSION="7\.0"

usage() {
echo "Usage: $(basename $0) [-h|--help] <cuda version to be used>
Expand All @@ -49,16 +51,20 @@ check_cuda_version() {

check_cuda_version "$TO_VERSION"

if [ $TO_VERSION = "8.0" ]; then
FROM_BINARY="-7\.5"
TO_BINARY="-8\.0"
FROM_VERSION=$CUDA_75_VERSION
TO_VERSION=$CUDA_80_VERSION
else
if [ $TO_VERSION = "9.0" ]; then
FROM_BINARY="-8\.0"
TO_BINARY="-7\.5"
TO_BINARY="-9\.0"
FROM_VERSION=$CUDA_80_VERSION
TO_VERSION=$CUDA_75_VERSION
TO_VERSION=$CUDA_90_VERSION
FROM_VERSION2=$CUDNN_60_VERSION
TO_VERSION2=$CUDNN_70_VERSION
else
FROM_BINARY="-9\.0"
TO_BINARY="-8\.0"
FROM_VERSION=$CUDA_90_VERSION
TO_VERSION=$CUDA_80_VERSION
FROM_VERSION2=$CUDNN_70_VERSION
TO_VERSION2=$CUDNN_60_VERSION
fi

sed_i() {
Expand All @@ -71,16 +77,20 @@ echo "Updating CUDA versions in pom.xml files to CUDA $1";

BASEDIR=$(dirname $0)

#Artifact ids, ending with "-7.5" or "-8.0". nd4j-cuda, deeplearning4j-cuda, etc.
#Artifact ids, ending with "-8.0" or "-9.0". nd4j-cuda, deeplearning4j-cuda, etc.
find "$BASEDIR" -name 'pom.xml' -not -path '*target*' \
-exec bash -c "sed_i 's/\(artifactId>.*\)'$FROM_BINARY'<\/artifactId>/\1'$TO_BINARY'<\/artifactId>/g' {}" \;

#Artifact ids, ending with "-7.5-platform" or "-8.0-platform". nd4j-cuda-platform, etc.
#Artifact ids, ending with "-8.0-platform" or "-9.0-platform". nd4j-cuda-platform, etc.
find "$BASEDIR" -name 'pom.xml' -not -path '*target*' \
-exec bash -c "sed_i 's/\(artifactId>.*\)'$FROM_BINARY'-platform<\/artifactId>/\1'$TO_BINARY'-platform<\/artifactId>/g' {}" \;

#CUDA versions, like <cuda.version>7.5</cuda.version>
#CUDA versions, like <cuda.version>9.0</cuda.version>
find "$BASEDIR" -name 'pom.xml' -not -path '*target*' \
-exec bash -c "sed_i 's/\(cuda.version>\)'$FROM_VERSION'<\/cuda.version>/\1'$TO_VERSION'<\/cuda.version>/g' {}" \;

#cuDNN versions, like <cudnn.version>7.0</cudnn.version>
find "$BASEDIR" -name 'pom.xml' -not -path '*target*' \
-exec bash -c "sed_i 's/\(cudnn.version>\)'$FROM_VERSION2'<\/cudnn.version>/\1'$TO_VERSION2'<\/cudnn.version>/g' {}" \;

echo "Done updating CUDA versions.";
2 changes: 1 addition & 1 deletion deeplearning4j-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-8.0</artifactId>
<artifactId>nd4j-cuda-9.0</artifactId>
<version>${nd4j.version}</version>
<scope>test</scope>
</dependency>
Expand Down
6 changes: 3 additions & 3 deletions deeplearning4j-cuda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>deeplearning4j-cuda-8.0</artifactId>
<artifactId>deeplearning4j-cuda-9.0</artifactId>
<name>deeplearning4j-cuda</name>
<parent>
<groupId>org.deeplearning4j</groupId>
Expand All @@ -27,8 +27,8 @@
</parent>

<properties>
<cuda.version>8.0</cuda.version>
<cudnn.version>6.0</cudnn.version>
<cuda.version>9.0</cuda.version>
<cudnn.version>7.0</cudnn.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Pair<Gradient, INDArray> backpropGradient(INDArray input, INDArray weight
srcStride[0], srcStride[1], srcStride[2], srcStride[3]));
checkCudnn(cudnnSetTensor4dDescriptorEx(cudnnContext.deltaTensorDesc, dataType, miniBatch, outDepth, outH, outW,
deltaStride[0], deltaStride[1], deltaStride[2], deltaStride[3]));
checkCudnn(cudnnSetConvolution2dDescriptor_v5(cudnnContext.convDesc, pad[0], pad[1], strides[0], strides[1], dilation[0],
checkCudnn(cudnnSetConvolution2dDescriptor(cudnnContext.convDesc, pad[0], pad[1], strides[0], strides[1], dilation[0],
dilation[1], CUDNN_CROSS_CORRELATION, dataType));
checkCudnn(cudnnSetFilter4dDescriptor(cudnnContext.filterDesc, dataType, tensorFormat, outDepth, inDepth, kH,
kW));
Expand Down Expand Up @@ -341,7 +341,7 @@ public INDArray preOutput(INDArray input, INDArray weights, INDArray bias, int[]
srcStride[0], srcStride[1], srcStride[2], srcStride[3]));
checkCudnn(cudnnSetFilter4dDescriptor(cudnnContext.filterDesc, dataType, tensorFormat, outDepth, inDepth, kH,
kW));
checkCudnn(cudnnSetConvolution2dDescriptor_v5(cudnnContext.convDesc, pad[0], pad[1], strides[0], strides[1], dilation[0],
checkCudnn(cudnnSetConvolution2dDescriptor(cudnnContext.convDesc, pad[0], pad[1], strides[0], strides[1], dilation[0],
dilation[1], CUDNN_CROSS_CORRELATION, dataType));

// find dimension of convolution output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ public FwdPassReturn activate(final Layer layer, final NeuralNetConfiguration co
checkCudnn(cudnnSetDropoutDescriptor(cudnnContext.dropoutDesc, cudnnContext, dropout, stateSpace, stateSize,
Nd4j.getRandom().getSeed()));

checkCudnn(cudnnSetRNNDescriptor(cudnnContext.rnnDesc, hiddenLayerSize, numLayers, cudnnContext.dropoutDesc,
CUDNN_LINEAR_INPUT, bidirectional ? CUDNN_BIDIRECTIONAL : CUDNN_UNIDIRECTIONAL, RNNMode,
dataType));
checkCudnn(cudnnSetRNNDescriptor_v6(cudnnContext, cudnnContext.rnnDesc, hiddenLayerSize, numLayers, cudnnContext.dropoutDesc,
CUDNN_LINEAR_INPUT, bidirectional ? CUDNN_BIDIRECTIONAL : CUDNN_UNIDIRECTIONAL, RNNMode,
CUDNN_RNN_ALGO_STANDARD, dataType));

cudnnTensorStruct xDesc0 = xDesc.get(cudnnTensorStruct.class, 0);
checkCudnn(cudnnGetRNNParamsSize(cudnnContext, cudnnContext.rnnDesc, xDesc0, sizeInBytes, dataType));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-8.0</artifactId>
<artifactId>nd4j-cuda-9.0</artifactId>
<version>${nd4j.version}</version>
<scope>test</scope>
</dependency>
Expand Down

0 comments on commit 907d414

Please sign in to comment.