rsnk96 / Ubuntu-Setup-Scripts

Scripts to help you set up your Ubuntu quickly, especially if you're in any subfield of Data Science or AI!
Apache License 2.0
128 stars 76 forks source link

Detect CUDA install and configure OpenCV accordingly #74

Closed rajat2004 closed 4 years ago

rajat2004 commented 4 years ago

There is a way to find the Compute Capability, not exactly a command-line option, need to compile the following and run

#include <stdio.h>
#include "cuda.h"
int main() {
    cudaDeviceProp prop;
    cudaGetDeviceProperties(&prop, 0);
    printf("%d", prop.major * 10 + prop.minor);
}

But this won't work inside Docker I think while building, since there's no device yet Could add something like pass an env variable to the script, to automate this

rsnk96 commented 4 years ago

LGTM, would be nice to compile for the required Compute Capability only.

Also just need to verify if having comments in between the CMake command causes errors, I remember it did in the older versions of cmake. Doesn't seem to be causing an error in travis, will test on a system shortly and get back.

rajat2004 commented 4 years ago

The comments are after the cmake command has ended, will be obvious to someone who's changing the scripts by hand The code for checking the CC could be added as a file in the extras folder, but suppose when building a docker image, the device won't be present which would cause a problem A workaround could be that an env variable CUDA_ARCH_BIN or something could be passed to the script, if it's set, use that else we build for all supported CC >= 5.3

rajat2004 commented 4 years ago

Updated the flags to build for all supported architectures by default Some customization could be done, such as -

rsnk96 commented 4 years ago

Will leave those as upgrades to be made in the future

rajat2004 commented 4 years ago

Thanks for the review! Merged