From 90ddf95eea9d79e273235bf84a3aea2e2448dad8 Mon Sep 17 00:00:00 2001 From: Tero Karras Date: Fri, 13 Dec 2019 12:38:02 +0200 Subject: [PATCH] Fix test_nvcc.cu to work on Linux --- README.md | 8 +++----- test_nvcc.cu | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6afa3e0c..b6bb1468 100755 --- a/README.md +++ b/README.md @@ -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"`. @@ -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 | | :---------- | :------------: | :----: | :-----: | :----: | :---------- | diff --git a/test_nvcc.cu b/test_nvcc.cu index 9d3ce2dc..8b480412 100755 --- a/test_nvcc.cu +++ b/test_nvcc.cu @@ -6,19 +6,24 @@ #include +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; }