Skip to content

Commit

Permalink
Fix test_nvcc.cu to work on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
tkarras committed Dec 13, 2019
1 parent 512a156 commit 90ddf95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
8 changes: 3 additions & 5 deletions README.md
Expand Up @@ -43,10 +43,8 @@ StyleGAN2 relies on custom TensorFlow ops that are compiled on the fly using [NV

```.bash
nvcc test_nvcc.cu -o test_nvcc -run
| test_nvcc.cu
| Creating library test_nvcc.lib and object test_nvcc.exp
| CPU says hello!
| GPU says hello!
| CPU says hello.
| GPU says hello.
```

On Windows, the compilation requires Microsoft Visual Studio to be in `PATH`. We recommend installing [Visual Studio Community Edition](https://visualstudio.microsoft.com/vs/) and adding into `PATH` using `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"`.
Expand Down Expand Up @@ -183,7 +181,7 @@ python run_metrics.py --data-dir=~/datasets --network=gdrive:networks/stylegan2-

For other configurations, see the [StyleGAN2 Google Drive folder](https://drive.google.com/open?id=1QHc-yF5C3DChRwSdZKcx1w6K8JvSxQi7).

Note the metrics are evaluated using a different random seed each time, so the results will vary between runs. In the paper, we reported the average result of running each metric 10 times. The following table lists the available metrics along with their expected runtimes and random variation:
Note that the metrics are evaluated using a different random seed each time, so the results will vary between runs. In the paper, we reported the average result of running each metric 10 times. The following table lists the available metrics along with their expected runtimes and random variation:

| Metric | FFHQ config F | 1 GPU | 2 GPUs | 4 GPUs | Description |
| :---------- | :------------: | :----: | :-----: | :----: | :---------- |
Expand Down
21 changes: 13 additions & 8 deletions test_nvcc.cu
Expand Up @@ -6,19 +6,24 @@

#include <cstdio>

void checkCudaError(cudaError_t err)
{
if (err != cudaSuccess)
{
printf("%s: %s\n", cudaGetErrorName(err), cudaGetErrorString(err));
exit(1);
}
}

__global__ void cudaKernel(void)
{
printf("GPU says hello!\n");
printf("GPU says hello.\n");
}

int main(void)
{
printf("CPU says hello!\n");
cudaError_t err = cudaLaunchKernel(cudaKernel, 1, 1, NULL, 0, NULL);
if (err != cudaSuccess)
{
printf("%s: %s\n", cudaGetErrorName(err), cudaGetErrorString(err));
return 1;
}
printf("CPU says hello.\n");
checkCudaError(cudaLaunchKernel((void*)cudaKernel, 1, 1, NULL, 0, NULL));
checkCudaError(cudaDeviceSynchronize());
return 0;
}

0 comments on commit 90ddf95

Please sign in to comment.