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

Error with calling Cosmic-conn from py script on Gemini GMOS 2D spec #12

Open
Karuntg opened this issue Apr 5, 2023 · 2 comments
Open

Comments

@Karuntg
Copy link

Karuntg commented Apr 5, 2023

Hi Chengyuan
I tried Cosmic-conn from within a script based on the example you had given. I am running this on the same Gemini GMOS 2D spec, as in my earlier issue.I have copied the code below for ref. The script reads and loads the data now, but the error I get is:

[W NNPACK.cpp:51] Could not initialize NNPACK! Reason: Unsupported hardware.

I don't have GPU on this machine, but think Cosmic-conn automatically reverts to the slower CPU version?

pls let me know
thx
karun

Here is my simple script:

script to run cosmic-conn on command line

import numpy as np
from astropy import *
import astropy.io.fits as pyfits
from astropy.stats import sigma_clipped_stats

read in the transf 2d spec

datadir = '/copiapo1/karun/Cosmic_COnn/cr_tst/'
fits = 'tgsqgsS20221115S0065.fits'
sci = 2 # extension number of science

read data into array

fits_path = datadir+fits
data = pyfits.getdata(fits_path,ext=sci)
head = pyfits.getheader(fits_path, ext=sci)

shap = data.shape
print(shap)
rows,cols = shap[0],shap[1]
print('Size of 2D spec: ',rows,cols)

from cosmic_conn import init_model

initialize a Cosmic-CoNN model

cr_model = init_model("ground_imaging")

the model outputs a CR probability map in np.float32

data = data.astype(np.float32)
cr_prob = cr_model.detect_cr(data)

convert the probability map to a boolean mask with a 0.5 threshold

cr_mask = cr_prob > 0.5

@cy-xu
Copy link
Owner

cy-xu commented Apr 5, 2023

Hi Karun,

Your code looks good, and the "[W NNPACK.cpp:51] Could not initialize NNPACK! Reason: Unsupported hardware." message is not an error but more like a warning.

NNPACK is for hardware acceleration and if you were using an unsupported CPU like the ARM-based M1 Mac, you would see this message. It's just slower and I have double-checked that you will get identical results.

Similar discussion -- https://discuss.pytorch.org/t/bug-w-nnpack-cpp-80-could-not-initialize-nnpack-reason-unsupported-hardware/107518/13

So you don't have to worry about your hardware or this message if you are not processing thousands of files, i.e., if performance is not a concern. I hope this helps.

Best,
CY

@Karuntg
Copy link
Author

Karuntg commented Apr 5, 2023

Hi CY, thanks much, good to know. With this initial testing, once i get more familiar with Cosmic-cnn, i plan to run it on multiple files on a cluster with GPU acceleration
thx
karun

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