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

Question about failing to save an image (Normal situation) #178

Open
lasiyan opened this issue Nov 13, 2023 · 1 comment
Open

Question about failing to save an image (Normal situation) #178

lasiyan opened this issue Nov 13, 2023 · 1 comment

Comments

@lasiyan
Copy link

lasiyan commented Nov 13, 2023

[Environment]

  • Jetson Orin AGX (Jetpack 5.0.1) GCC 9.4.0 (stdc++ 17)

[Question]

The simple code below should work fine when running in debugging mode using gdb.

But strangely, when I run it directly from the terminal (e.g. ./myAPP), I get failed on saveImage.

Have you experienced similar symptoms?

I suspected a synchronization problem and added cudaDeviceSynchronize right after loadImage and saveImage, but it doesn't improve.

void run()
{
  Log::SetLevel(Log::Level::DEBUG);

  uchar3* img;
  int w, h;
  if (!loadImage("test.jpg", &img, &w, &h)) {
    printf("loadImage fail\n");
  }
  CUDA(cudaDeviceSynchronize());

  printf("%02X %02X %02X\n", img->x, img->y, img->z);

  if (!saveImage("res_org.jpg", img, w, h)) {
    printf("saveImage fail\n");
  }
  CUDA(cudaDeviceSynchronize());
  CUDA(cudaFreeHost(img));
}

Below are the results of the run. Is there a way to view the verbose log instead of SetLevel?

[image]  loaded 'test.jpg'  (1920x1080, 3 channels)
[cuda]   cudaAllocMapped 6220800 bytes, CPU 0x203d8e000 GPU 0x203d8e000
24 26 21
[image]  failed to save 1920x1080 image to 'res_org.jpg'
saveImage fail

I referenced this article. I'm new to CUDA, so please bear with me.

@dusty-nv
Copy link
Owner

Hi @lasiyan, here is the code to saveImage()

bool saveImage( const char* filename, void* ptr, int width, int height, imageFormat format, int quality, const float2& pixel_range, bool sync )

in this case, it checks the result from stbi_write_jpg() 3rd-party library function, and I'm not sure why that would work ok normally but fail under GDB

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

No branches or pull requests

2 participants