fix(ml): suppress unsafe-code warning on startup env::set_var calls
CUBLAS_WORKSPACE_CONFIG and NVIDIA_TF32_OVERRIDE are set once at startup before any threads or CUDA work begins. The unsafe block is correct but triggers -W unsafe-code. Adding #[allow(unsafe_code)] at the call site silences the warning while keeping the safety comment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -413,6 +413,7 @@ fn main() -> Result<()> {
|
||||
// Pre-allocate CUBLAS workspace for deterministic + faster tensor core ops.
|
||||
// Enable TF32 for all FP32 matmuls — ~8x throughput on H100 tensor cores.
|
||||
// SAFETY: called once at startup before any multi-threading or CUDA work begins.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
std::env::set_var("CUBLAS_WORKSPACE_CONFIG", ":4096:8");
|
||||
std::env::set_var("NVIDIA_TF32_OVERRIDE", "1");
|
||||
|
||||
@@ -1042,6 +1042,7 @@ fn main() -> Result<()> {
|
||||
// Pre-allocate CUBLAS workspace for deterministic + faster tensor core ops.
|
||||
// Enable TF32 for all FP32 matmuls — ~8x throughput on H100 tensor cores.
|
||||
// SAFETY: called once at startup before any multi-threading or CUDA work begins.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
std::env::set_var("CUBLAS_WORKSPACE_CONFIG", ":4096:8");
|
||||
std::env::set_var("NVIDIA_TF32_OVERRIDE", "1");
|
||||
|
||||
Reference in New Issue
Block a user