Comments (6)
This means it is Send, but not Sync.
Feel free to open a PR for adding Send to Cudnn
I hope you can see from that, that "thread-safe" is not the same as being "Sync".
A type is Sync if it is safe to share between threads (T is Sync if and only if &T is Send).
is the quote from rust docs. My interpretation of the cuda driver api being threadsafe is that the functions it contains are safe to call at the exact same time with the same objects from multiple threads.
What am I missing?
With certain exceptions around graph usage
The safe level api for driver doesn't actually use any of the graph functions (and actually we haven't even really exposed those at the result/sys level so It shouldn't be possible to call them), that's why I interpretted it as okay to mark as send/sync.
from cudarc.
It's mainly that the cuda driver api's cuda context (the main object in CudaDevice) itself is threadsafe:
The CUDA driver API supports multiple threads using the same context. The CUDA driver API is thread safe with certain exceptions around graph usage. You may still hit a memory limit at some point.
Note that I can't really find anything in the main documentation about this, but this sentiment is echoed multiple places online.
There are other apis (like cudnn) that are not and so we don't impl Send/Sync for them:
The cuDNN library is thread-safe. Its functions can be called from multiple host threads, so long as the threads do not share the same cuDNN handle simultaneously.
Which is confusing because the above basically means it isn't thread safe to me 🤣
from cudarc.
The cuDNN library is thread-safe. Its functions can be called from multiple host threads, so long as the threads do not share the same cuDNN handle simultaneously.
This means it is Send, but not Sync.
from cudarc.
I hope you can see from that, that "thread-safe" is not the same as being "Sync".
from cudarc.
"With certain exceptions around graph usage" also suggests CudaDevice is neither Send nor Sync, if those exceptions are reachable from the provided API (if they require unsafe
ly going behind cudarc's back, then all is well, though you should communicate this concern to programmers using this library, probably).
from cudarc.
The safe level api for driver doesn't actually use any of the graph functions
Oh okay! Then we don't have to worry about the graph exceptions. You should probably note "make these unsafe to call if they get exposed?" in some issue or the library's internal FIXME/TODOs but yeah.
My interpretation of the cuda driver api being threadsafe is that the functions it contains are safe to call at the exact same time with the same objects from multiple threads.
What am I missing?
I think you are fully understanding the premise, and I suppose we mostly have a difference of opinion that if a programmer that is not familiar with Rust's paradigm of thread-safety and the difference between T: Sync
and T:Send
says something is "thread-safe", then I think this should be interpreted as having very little weight.
This is because I have seen widely-hailed experts claim something is "thread safe" to call, and then say it is "thread safe... if you only call it once", which... according to Rust, that isn't very thread-safe!
from cudarc.
Related Issues (20)
- Issue for building my rust application with cudarc v0.11.1 (Unsupported cuda toolkit version: `10010`) HOT 1
- Unable to find curand lib under the names ... HOT 1
- how to specify the following features cuda-version-from-build-system, cuda-12040, cuda-12030, cuda-12020, cuda-12010, cuda-12000, cuda-11080, cuda-11070 HOT 3
- Error: unsupported CUDA toolkit 11.5 HOT 4
- Unable to find nvrtc lib under the names ["nvrtc", "nvrtc64", "nvrtc64_12", "nvrtc64_125", "nvrtc64_125_0", "nvrtc64_120_5", "nvrtc64_10"]. Please open GitHub issue. HOT 1
- Safe API call to get device name and compute capability? HOT 2
- CUDA_ERROR_NO_DEVICE "no CUDA-capable device is detected" HOT 9
- Unable to find cuda lib under the names ["cuda", "nvcuda"] on WSL HOT 1
- Is there a way to get this to compile on a Mac? HOT 3
- Unified memory support HOT 1
- In-Place Reduction for NCCL HOT 1
- Cannot find cudnn libs/headers HOT 3
- Not able to include <stddef.h> + etc. when compiling? HOT 2
- cuMemAdvise_v2 and cuMemPrefetchAsync_v2 driver functions aren't available in older cuda compilation tool <12.0.20 HOT 4
- Why must `bind_to_thread` be called before using `CudaDevice` on a separate thread? HOT 3
- What part of `&CudaSlice<T>` can be mutated by a `CudaFunction`? HOT 3
- cudarc fails to load libraries on official nvidia ubuntu images HOT 8
- Current destructor strategy yields panic-in-panic HOT 6
- PTX JIT compile error? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cudarc.