Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- run: |
. .travis/ci-system-setup.sh
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"
env:
RUNNER_ENVIRONMENT: ${{ runner.environment }}

Expand All @@ -45,6 +46,7 @@ jobs:
- run: |
. .travis/ci-system-setup.sh
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"
env:
RUNNER_ENVIRONMENT: ${{ runner.environment }}

Expand Down
6 changes: 6 additions & 0 deletions .travis/ci-system-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ then
touch /tmp/ci-setup-done
fi

if [ -e /usr/local/cuda ]
then
PATH=$PATH:/usr/local/cuda/bin
nvcc --version
fi

S3=https://s3.amazonaws.com/tract-ci-builds/tests

if [ "$GITHUB_WORKFLOW" = "Metal tests" -o "$GITHUB_WORKFLOW" = "CUDA tests" ]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ clap = { version = "~3.1", features = [ "cargo" ] }
colorous = "1.0.5"
core_affinity = "0.8.0"
criterion = "0.6"
cudarc = { version = "0.16.4", features = ["dynamic-loading", "cuda-12060", "f16"] }
cudarc = { version = "0.17", features = ["dynamic-loading", "cuda-version-from-build-system", "f16"] }
derive-new = "0.5.9"
dinghy-test = "0.6"
downcast-rs = "1.2.0"
Expand Down
8 changes: 6 additions & 2 deletions cuda/src/kernels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ mod unary;
mod utils;

use crate::ops::GgmlQuantQ81Fact;
use std::mem::transmute;

use crate::tensor::{CudaBuffer, CudaTensor};
use anyhow::{bail, ensure};
pub use binary::BinOps;
Expand Down Expand Up @@ -159,7 +161,9 @@ pub fn get_sliced_cuda_view_mut(
len: usize,
) -> TractResult<CudaViewMut<'_, u8>> {
ensure!(offset + len <= t.len() * t.datum_type().size_of());
let mut buffer = t.device_buffer().downcast_ref::<CudaBuffer>().unwrap();
let buffer: &CudaBuffer = t.device_buffer().downcast_ref::<CudaBuffer>().unwrap();
let offset = t.buffer_offset::<usize>() + offset;
Ok(buffer.as_view_mut().slice_mut(offset..(offset + len)))
let ptr: *const CudaBuffer = buffer;
let mut_buffer: &mut CudaBuffer = unsafe { (ptr as *mut CudaBuffer).as_mut().unwrap() };
Ok(mut_buffer.as_view_mut().slice_mut(offset..(offset + len)))
}
8 changes: 7 additions & 1 deletion cuda/src/tensor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ops::Deref;
use std::ops::{Deref, DerefMut};

use cudarc::driver::{CudaSlice, DevicePtr};
use tract_core::internal::tract_smallvec::ToSmallVec;
Expand Down Expand Up @@ -30,6 +30,12 @@ impl Deref for CudaBuffer {
}
}

impl DerefMut for CudaBuffer {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}

#[derive(Clone)]
pub struct CudaTensor {
buffer: Arc<CudaBuffer>,
Expand Down
Loading