Skip to content

Commit

Permalink
Upgrade to CUDA 9.0 (#2161)
Browse files Browse the repository at this point in the history
* Upgrade to CUDA 9.0

* sparse reallocate logic micro fix

* Change javacpp-presets back to release version for CUDA
  • Loading branch information
saudet authored and raver119 committed Oct 4, 2017
1 parent e11435e commit febf2ea
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 29 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.";
6 changes: 3 additions & 3 deletions nd4j-backends/nd4j-backend-impls/nd4j-cuda-platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>nd4j-cuda-8.0-platform</artifactId>
<artifactId>nd4j-cuda-9.0-platform</artifactId>
<name>nd4j-cuda-platform</name>

<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>
<nd4j.backend>nd4j-cuda-${cuda.version}</nd4j.backend>
</properties>

Expand Down
6 changes: 3 additions & 3 deletions nd4j-backends/nd4j-backend-impls/nd4j-cuda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>nd4j-cuda-8.0</artifactId>
<artifactId>nd4j-cuda-9.0</artifactId>
<name>nd4j-cuda</name>

<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>
<env.LIBND4J_HOME>${basedir}/../../../../libnd4j/</env.LIBND4J_HOME>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ protected void hgemm(char Order, char TransA, char TransB, int M, int N, int K,

int arch = CudaEnvironment.getInstance().getCurrentDeviceArchitecture();

if (CUDA_VERSION == 8000 && (arch == 53 || arch == 60)) {
if (CUDA_VERSION >= 8000 && (arch == 53 || arch == 60)) {
// on these selected archs we run with cublasHgemm
__half alphaHalf = new __half();
__half betaHalf = new __half();
new ShortPointer(alphaHalf).put((short) HalfIndexer.fromFloat(alpha));
new ShortPointer(betaHalf).put((short) HalfIndexer.fromFloat(beta));

cublasHgemm(new cublasContext(handle), convertTranspose(TransA), convertTranspose(TransB), M, N, K,
new __half().x((short) HalfIndexer.fromFloat(alpha)),
new __half(cAPointer.getDevicePointer()), lda, new __half(cBPointer.getDevicePointer()),
ldb, new __half().x((short) HalfIndexer.fromFloat(beta)),
alphaHalf, new __half(cAPointer.getDevicePointer()), lda,
new __half(cBPointer.getDevicePointer()), ldb, betaHalf,
new __half(cCPointer.getDevicePointer()), ldc);
} else {
// CUDA_R_16F == 2 for CUDA 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ public DataBuffer reallocate(long length) {
pointer.address();

// we need to update length with new value now
this.length = length;
//this.length = length;
if(isAttached()){
// do nothing here, that's workspaces
} else{
Expand All @@ -1134,6 +1134,11 @@ public DataBuffer reallocate(long length) {
return this;
}

@Override
public long capacity() {
return pointer.capacity();
}

/*
protected short fromFloat( float fval ) {
int fbits = Float.floatToIntBits( fval );
Expand Down
4 changes: 2 additions & 2 deletions nd4j-backends/nd4j-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@

<!--<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-8.0</artifactId>
<artifactId>nd4j-cuda-9.0</artifactId>
<version>${project.version}</version>
</dependency>-->

<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<artifactId>nd4j-cuda-9.0</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ public DataBuffer reallocate(long length) {
}
}
Pointer.memcpy(pointer, oldPointer, this.length() * getElementSize());
this.underlyingLength = length;
//this.underlyingLength = length;
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions nd4j-uberjar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@
<dependencies>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-8.0</artifactId>
<artifactId>nd4j-cuda-9.0</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-8.0-platform</artifactId>
<artifactId>nd4j-cuda-9.0-platform</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand Down

0 comments on commit febf2ea

Please sign in to comment.