Jupyter notebook compiling the code but not displaying the output!


The code as seen in the image is compiling but not displaying any output.
I am new to Jupyter notebook so I am not sure how to resolve this issue by myself.

Thank you in advance

Please review how to ask for help in the post Getting good answers to your questions .

My guess is that your issue isn’t a Jupyter question and that if you ran this code as a basic Python script, you’d have the same issues. However, it is hard to tell if it is pertinent to this forum or not because you shared your large code block as an image that cannot be used by anyone who would attempt to test or evaluate your code. One thing that would help, even if you end up seeking help in a more general or module-specific location, is if you learn how to share notebooks and code using https://gist.github.com/ or Github and then provide the link to that. There are other places where you can easily share snippets of code even without registering, such as Pastebin. If your code block was somewhat smaller, I’d encourage you to paste it directly into this forum using what is described in the section ’ Block code formatting’ here.

If the code comes from somewhere else, then point those who could help you at the source as a way to provide them the code.

Include any information about what to expect if it does run correctly.

1 Like

Here is the link to the Github page,

In this link it shows the output for this exact code but when i try to execute it, it does not give me anything.

Hope it helps!!
@fomightez

It runs for me AFTER I MOVE figure1.ipynb OUT OF examples AND UP TO ROOT.

Are you using the cloned repo to run things with the same directory hierarchy as GitHub - riscv-newop/riscv-newop: A RISC-V new instruction discovery tool [Work in Progress] ? If so, just move the notebook up so it is in the same directory with the directory embench_hst.

Uncomment the following lines if you want to see plots as it runs:

plt.clf()
plt.plot([x for x in range(len(new_instructions))],list(map(lambda x:x/total_cycles, accumulate([sg.score for sg in new_instructions]))))
plt.show()

I’m not seeing a Jupyter issue. I’m guessing you didn’t write this code and are trying to run it? If so, by evaluating what [x for x in glob("./embench_hst/*.hst") if x not in floating_point_hsts] gave by running print([x for x in glob("./embench_hst/*.hst") if x not in floating_point_hsts]) above the for loop, you would have determined that list was empty and so it was iterating on nothing and therefore processing no files. That’s why in your image you saw that cell run and produce nothing. It seems the person who wrote the code, either had the example notebooks or the directory embench_hst differently arranged then in the current version of this repo and you have to adjust where things are pointing or move them to recreate that.


For assignment of floating_point_hsts and other uses if map(lambda), you may want to see here.

@fomightez ,
First of all, tank you for the help.

I have put both embench_hst and the notebook folder in the same directory as you suggested.
But that did not solve the problem for me as it was still showing no output.
so I tried to put the embench_hst folder inside the notebook folder and tried to run my code but i got some errors.


If it is not too much trouble, may i know what exactly you did to get the output.
Thank you

Certainly. I can do better than that thanks to MyBinder.org, and give you direct access to see what I am doing and an active session where it works.

The direct link to an active Jupyter session served by the MyBinder system where the notebook works can be found by clicking the launcg button below:

badge

Once the notebook opens, click Cell > Run all from the menu just above the notebook to run the notebook in your browser.

All that is really doing is using a URL to point my fork of the repo at the MyBinder service using, the actual URL below:

https://mybinder.org/v2/gh/fomightez/riscv-newop/HEAD?filepath=figure1.ipynb

If you copy that URL and paste it in your browser, you’ll end up at a similar (but isolated & different) session.

My actual fork of this repo can be found here. I edited the README to add a link to the Binder session with the notebook we’ve been discussing. And I added a binder directory to add configuration files that the Binder system will use. I unpinned the dependencies to get the current ones because that is who I ran it yesterday. That stuff is all rather superficial/less important. The real action here that makes the session that spins up different from just git cloning the original repo in a python environment is being contributed by the move command in the postBuild configuration file. That line mv examples/figure1.ipynb . bakes into the image the MyBinder ultimately launches a change in the location of figure1.ipynb. The active session you get served when you click the launch button above, the notebook is up in the root directory. You can see that by typing ls in a cell in the notebook and running it. (To see the working directory you are in when the session starts put pwd in a cell and run it.)

It’s important to note that in my fork, I didn’t actually yet move the notebook. It gets moved somewhere between when the MyBinder service clones my fork of repo and serves up a session to you. Because this notebook works when it is moved, a valid next step may be to actually move it in my fork and then I’d remove that line from the postBuild. However, you are just looking to get things working and so I shouldn’t need to work on this more.



I think you see the error you last posted because you have to use the version of rvnewop that is in the root directory. By moving the notebook up to the root, you insure you are using that one. You’ll note in binder/requirements.txt I don’t include that package in the list. Note that the latest version at PyPi.org that pip installs is only from July 10, 2020 and the one in the repo is much newer and has undergone a lot of updating in that time.

@fomightez
OH MY GOD!!
Thank you so much for this!!
Is it ok if I delete the cloned files that I already have and reclone the files with the changes that u have made from the Github link that u have provided?
It should work fine ryt without me moving files around ?
I am using jupyter notebook on ubuntu.
I am not sure what is a root file.Right now, i have the notebook folder inside a directory that contains all the files like embench_hst, examples, rvnewop…
I am also trying to execute figure 2 3 and 4.
So where exactly do i put the notebook folder and the figure programs.
Also, instead of FILENAME, i want to run it with a dump file of my code.

Recloning my fork won’t work. Note in my post I that I say I didn’t actually change the files yet. Essentially I gave you access to a running machine where I had done what you should do.

But there’s no need to really do that. You can easily move the files.

If you want to begin over, delete your local clone of the https://github.com/riscv-newop/riscv-newop repo. Re-clone https://github.com/riscv-newop/riscv-newop and move the notebooks by running the following on your command line wherever you are working:

git clone https://github.com/riscv-newop/riscv-newop.git
cd riscv-newop
mv examples/* .

Now you should be able to run figure1.ipynb. And I suspect the other notebooks that were formerly in examples; however, I didn’t test those. Maybe the person who made the repo actually meant them to be located in examples. It’s hard to say, but I’m hopeful with what you’ve learned you can discern that. All I know about is that as figure1.ipynb is written, it is meant to be in the same directory with BOTH rvnewop and embench_hst directories. In other words, you can imagine the maybe first figure notebook was written before the examples directory existed and then later all the other ones were developed in the examples directory and then figure1.ipynb was thrown in examples later, long after it had been run. You have to look at the code in the others and figure that out. I would suggest learning more Python and Unix as soon as possible. And keep in mind this clearly says ‘[Work in Progress]’ at https://github.com/riscv-newop/riscv-newop, some of the code might not even be done.


RELATED:
Sorry, you probably aren’t workin in root since you are on local computer. But you want to put the notebooks in the equivalent of the root directory of the cloned repo where the rvnewop and embench_hst directories BOTH are. Which the commands above will do.


Not following what you mean by this below:

Could you explain?

@fomightez
In the figure 1 code, you might notice something called FILENAME.
So this is basically a code that is imported inside this figure 1 code to get the outputs that u get.
It is basically measuring some sort of performance of that code.
But instead of FILENAME, i want to get the performance for my c code which i have dumped into the assembly file ie…file.dump. I want to run figure code for the dump file to get an output.

@fomightez
If it is ok with you, I can share my screen using AnyDesk and you can take a look at what is what.
Again, only if you don’t mind.

Okay. If I am understanding what you mean, the easiest thing to do would be to move the current contents of embench_hst into a sub-directory in embench_hst and put your version of those files in there. Your files would need to end in .hst. If they don’t, you need to edit the line below so the glob pattern matches your files:

for FILENAME in [x for x in glob("./embench_hst/*.hst")]:

In other words if you add a line print([x for x in glob("./embench_hst/*.hst")]) (or your equivalent code in the print statement) before the for loop, you should see a list of the files you want to iterate on.