Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose env var to disallow cuda #1834

Closed
wants to merge 1 commit into from

Conversation

IanButterworth
Copy link
Contributor

While it's possible to set Flux.use_cuda[] = false, on some machines with underpowered but cuda-functional gpus, it would be nice to have a more system-wide permanent way to opt out of cuda.

So this adds env var FLUX_DISALLOW_CUDA which can be set to "true" etc. to disallow cuda

@DhairyaLGandhi
Copy link
Member

DhairyaLGandhi commented Jan 14, 2022

Thanks Ian! Should we instruct users to set CUDA_VISIBLE_DEVICES instead? That seems more future proof.

@IanButterworth
Copy link
Contributor Author

Yeah, that sounds good. I didn't know about that (for anyone else that didn't https://developer.nvidia.com/blog/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/)

As long as it appears in a google for "Flux disable CUDA" then I'd have caught it.

@mcabbott
Copy link
Member

Can this disable the loading completely? @time using CUDA is about 4 seconds for me, the second time, and much more if things have been updated since the last time.

@DhairyaLGandhi
Copy link
Member

Since CUDA the symbol is already in the flux namespace that might lead to dirtier code in the repo.

@mcabbott
Copy link
Member

mcabbott commented Jan 14, 2022

What does "might lead to dirtier code" even mean?

Loading CUDA unconditionally is literally half the loading time of Flux. If it can be avoided, that's a huge win. If it has to be in breaking v0.13, that's fine.

But I haven't tried, there may be some actual problem with this idea.

If possible, it would be nicest if the solution could be shared with other packages. Which means CUDA_VISIBLE_DEVICES sounds like it's probably the right thing. But does it have a standard way to encode "none"?

@darsnack
Copy link
Member

It's possible that we can set use_cuda[] to false early only in the case that CUDA_VISIBLE_DEVICES is empty (and drop out before calling CUDA.functional() otherwise). The downside (which is what I think Dhairya meant) is that any reference to CUDA.jl stuff will need to be guarded by a use_cuda[] check.

@mcabbott
Copy link
Member

Yes, on searching, there is more random CuArray code scattered about than I remembered. Although most of it should really move to NNlibCUDA. Maybe that's a bigger project than Ian has volunteered for... no downside to small steps first.

@CarloLucibello
Copy link
Member

Instead of adding a new env variable, we can just document

export CUDA_VISIBLE_DEVICES=""

or more generally the use of CUDA_VISIBLE_DEVICES

bors bot added a commit that referenced this pull request Jan 15, 2022
1835: Document disabling GPUs r=DhairyaLGandhi a=DhairyaLGandhi

From the discussion in #1834

1836: Try using latest cu(DNN) binaries r=DhairyaLGandhi a=ToucheSir

Possible alternative to #1822.

Co-authored-by: Dhairya Gandhi <dhairya@juliacomputing.com>
Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
@DhairyaLGandhi
Copy link
Member

@IanButterworth do we need this still?

@IanButterworth
Copy link
Contributor Author

I don't think so. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants