Comments (6)
Hi @beibeijiang, can you provide a short, reproducible script of how you are doing this locking and GPU availability detection? Are you just using gpuInfo()
and checking the available
field? As far as I know, there isn't a way in OpenCL to detect how much RAM is currently available on a GPU (I will need to look around some more to be sure).
from gpur.
GPUsetWorkContext <- function(lock.p = "/var/lock/GPU/lock",...){
ngpu <- detectGPUs()
gpubusy.count <- 0
for (i in 1:ngpu) {
gpulock <- paste(lock.p, i, sep = "")
if(!file.exists(gpulock)){
setContext(i)
file.create(gpulock)
return(i)
break
}
else
gpubusy.count <- gpubusy.count + 1
}
if(gpubusy.count == ngpu){
cat("Error: no avaliable resource!\n")
q(save = "no")
}
}
lock.path = "/var/lock/GPU/lock"
#search free gpu and set working gpu
gpuid <- GPUsetWorkContext(lock.p = lock.path)
...# core functions
#finish work, remove the lock file
file.remove(paste(lock.path, gpuid, sep = "")
from gpur.
@beibeijiang I would recommend using a tryCatch
statement around whatever process you are using so that if it fails it has an exception handler to remove the 'lock' file. For example, some pseudo-code would look like this:
result = tryCatch({
# the gpu call
expr
}, error = function(e) {
# error handler code
print(paste0("the following error happend: ", e))
file.remove(paste(lock.path, gpuid, sep = ""))
}, finally = {
# cleanup code
rm(object)
gc()
file.remove(paste(lock.path, gpuid, sep = ""))
}
from gpur.
@cdeterman Many thanks for your work and help. It works well.
Look forward to your parallel version of gpuR().
from gpur.
@beibeijiang glad it solved your current problem. The parallel version of gpuR is somewhat complicated do to the fact that R itself is not internally thread safe. I think users may be able to use parallel backends like foreach
so long as they don't intend to return any gpuR
objects such as gpuMatrix/vclMatrix
but this requires some further testing. Given this unforeseen complication the parallel version is likely going to be pushed back to either version 1.3.0 or potentially a separate package. I'm still not sure at the moment.
from gpur.
@cdeterman I understand. It takes time to figure out the gpuR parallel Currently I could split the input into chunks then submit simple R script into different gpu. It works well. This is also good for running jobs on gpu cluster. I am satisfied with the high performance. You have already made great work. It helps me a lot. Thank you very much.
from gpur.
Related Issues (20)
- Add 'cor' functionality
- The error, when I intall gpuR package
- Eigen Calculation in gpuR
- unable to find an inherited method for function ‘as.gpuMatrix’ for signature ‘"matrix"’
- gpuR install error for debian 9: error: ViennaCL: FATAL ERROR: ViennaCL encountered an unknown OpenCL error.
- OpenCL error after trouble finding libOpenCL during install
- R CMD check error on matrix initialization HOT 2
- List of compatible GPUs? HOT 1
- Why does an R package based on gpuR not work? HOT 4
- No intel IGD when nvidia card installer.
- R package using gpuR fails to pass R CMD check in windows
- rocm install
- wich method
- Is this package still maintained? HOT 3
- Does gpuR work with the new Mesa? HOT 3
- gpuR with Intel HD graphics
- The package is not computing any tasks?
- A fatal error while compiling gpuR.
- NVIDIA RTX A2000 GPU not detected on Windows laptop
- i9-13900K & RTX 3090 working together, but only i9-13900K detected
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 gpur.