chiahao3 / uncorrected_ptycho

This repo presents my personal collection of code and data used for the paper "Achieving sub-0.5-angstrom–resolution ptychography in an uncorrected electron microscope"
5 stars 2 forks source link

The VS compiler issue when running the scripts #1

Open PhysXu opened 1 month ago

PhysXu commented 1 month ago

Hi, chiahao3,

Thanks very much for the sharing of your scripts and data.

When I tried the script of Fig_1d_10p3mrad_Talos_runPtycho.m, some warnings appeared. Please see the two snapshot below:

d167e5d4c9f6ec3ca5af6c71715be36

image

I am not sure whether it is OK, as the process could still continue.

However, when the script ran to the step of GPU l initialized ..., an error appeared. image

it looks like a Compiler issue. I tried to check the VS version. The version is 2022, which should be compatible:

6774a9cff3119968283bd5d9fa42f82

I get confused by the error above and want to know how to solve it.

chiahao3 commented 1 month ago

Hi @PhysXu , no problem! Sharing the code and data is my core believe of reproducible science and especially for computational microscopy like ptychography. If anything, I hope this encourages people to do the same for the community.

Hope these helps!

PhysXu commented 1 month ago

Hi, @chiahao3 , thanks very much for your reply and suggestions. Here is a quick feedback.

Sorry, I found that I made a stupid mistake. I have not installed the CUDA locally before.

After the installation of NVIDIA CUDA toolkit, now I have win 11, matlab2023b, Microsoft Visual Studio 2022, CUDA 12.2 on my local computer. The GPU in my PC is NVIDIA GeForce RTX 4080 SUPER.

I also tried to reinstall Microsoft Visual Studio 2022 with 'MSVC v140 - VS 2015 c++ build tools' by following your suggestion:

9db47e1f4edc92bc7411ccb62b41491 072e8f07db2aee7b834b5cec931cc19

However, the same error still exists: image

Need I uninstall MSVS 2022 and try MSVS 2019?

chiahao3 commented 1 month ago

Hi, although I'm no expert in neither Matlab, CUDA, or C++, I'll suggest let's try to split the problem into smaller chunks.

  1. Check if your local CUDA install is correct. Maybe run nvcc -V and nvidia-smi to check the version, and see if you have newer driver for your 4080 Super. If possible, find some simple CUDA task. In Python there're lots of packages that uses GPU via cudatoolkit like pytorch, tensorflow, cupy. If they can work, that means at least you have the GPU correctly identified and the driver should be ok.
  2. Look into more Matlab and CUDA support information. I'm not sure whether you only need CUDA, or you'll need nvcc (it's a compiler for CUDA code) as well for Matlab to do their mex thing.
  3. Try call some GPU function like gpuDevice in Matlab and see if it at least recognize your GPU device
  4. Last resort would be to check your MSVS version, either repair your MSVS2022 or try out 2019. I've attached my MSVS2022 version but I'm using Win10 which could have some impact as well. image

Overall I'll suggest that if you already spent more than 3 days on the environment setup, try to find someone with IT background, ideally with Matlab + GPU experience. I'm an electron microscopist by training and this is pretty much the best I can do 😂