One cell in my notebook executes for a long time, while the other CPU's in the machine are idle. Is it possible to run other cells in parallel?
Yes. Here is the documentation for ipyparallel (formerly IPython parallel) that will show you how to spawn multiple IPython kernel. After you are free to distribute the work across cores, and you can prefix cells with %%px0 %%px1... %%px999 (once set up) to execute a cell on a specific engine, which in practice correspond to parallel execution of cell. I would suggest having a look at Dask as well.
This does not answer your question directly but I think it would help a lot of people that are having the same problem. You can move variables between notebooks easily and then continue running the functions on another notebook then move the result back to the main notebook.
For example:
Notebook 1:
%store X
%store y
Notebook 2:
%store -r X
%store -r y
new_df = ...
%store new_df
Notebook 1:
%store -r new_df
I got very hopeful with Matt answer of the ipp module, but the truth is that the ipp does not run two cells in pararell. Ipp lets you work in two or more engines but not simultaneously.
Take this example, you run the first code and 1 second later you run the second code, each code in different cells:
%%px --targets 0
import time
for i in range(0,6):
time.sleep(1)
print(time.ctime())
Gives:
Thu Jun 16 10:30:53 2022
Thu Jun 16 10:30:54 2022
Thu Jun 16 10:30:55 2022
Thu Jun 16 10:30:56 2022
Thu Jun 16 10:30:57 2022
And
%%px --targets 1
import time
for i in range(0,6):
time.sleep(1)
print(time.ctime())
Gives:
Thu Jun 16 10:30:59 2022
Thu Jun 16 10:31:00 2022
Thu Jun 16 10:31:01 2022
Thu Jun 16 10:31:02 2022
Thu Jun 16 10:31:03 2022
So in conclusion, the cells are not running at the same time, they are just running in different engines. The second cell waits the 1st one to finish, and once it finishes the second cell starts.
Hope there is simple solution for this -.-
PD: Here is the image
Code in jupyter notebook
I want to introduce a library that has this feature, this does not require multiple notebooks tricks etc...
Parsl is the Productive parallel programming in Python
Configuration
import parsl
from parsl.app.app import python_app, bash_app
parsl.load()
As an example, I edited this snippet from parsl/parsl-tutorial.
# App that generates a random number after a delay
#python_app
def generate(limit,delay):
from random import randint
import time
time.sleep(delay)
return randint(1,limit)
# Generate 5 random numbers between 1 and 10
import time
st = time.time()
rand_nums = []
for i in range(5):
rand_nums.append(generate(10, 1))
# Wait for all apps to finish and collect the results
outputs = [i.result() for i in rand_nums]
et = time.time()
print(f"Execution time: {et - st:.2f}")
# Print results
print(outputs)
Result:
Execution time: 3.00
[1, 6, 4, 8, 3]
Note that the time it takes for the code to execute is 3s not 5s.
So what you can do is call the function (in this example is generate(...)) in a cell. This generate(...) will return a object. Then if you call the .result() on the object it will either:
Halt the program if it's waiting for the result.
Return the result if it's completed.
Therefore, as long as you call the .result() at the last few cells, the subroutine will be running in the background. And you can be sure at the last few cells the result can be obtained.
Regarding data dependencies, parsl is very smart, it will wait for the data that is dependent, even if it's decorated with the #python_app.
When someone wanted to leave a long-running calculation running in the background while running other things in the notebook, we were able to hack a solution using Python's multiprocesing. That allowed leaving a long-running cell running while running another cell in the classic notebook interface as well as Jupyterlab, see here.
Related
I have rtx 3090 gpu and i9 12th gen processor. my training is not too large as well and yet the training time is too long. When I begin the training phase it says 24 cores available but limiting to safe limit of only 8 cores. NUMEXPR_MAX_THREADS not set.
In your terminal add the NUMEXPR_MAX_THREADS to your terminal.
You can do so by writing in your CLI: export NUMEXPR_MAX_THREADS="24" if you want to use all of them. This will work until you close your terminal. You can add it permanently to your terminal profile (.bash_profile, ~/.zshrc ...)
Regarding slow execution, that depends on your rasa config choices and the number of stories/rules.
Finally, you need to pass the param use_gpu = True in your config for TedPolicy t make it train TED faster.
I've searched to try and find the answer to this question, but unfortunately, information is few and far between.
I need to be able to open multiple instances of GNU Octave to run a script which will convert a file. Each file takes approximately 5 minutes to convert, so for 10 files I'm waiting nearly 50 minutes.
However, I can (and have) manually open 10 instances of Octave and run the script manually in each instance. Is there a way to do this programmatically? So if I had 10 files, 10 different instances of Octave would open and each would run the script to convert 1 file. These conversions aren't dependent on each other, but if it's simple enough to communicate between the different instances of Octave, that would be a "nice to know".
I believe you can use some of the high-level commands, like system and popen which Octave include for starting subprocesses. These subprocesses allow you to start new tasks or start another program. After performing the tasks it can observe the output, which is a way to communicate with the main program that starts the subprocesses.
You should take a look at the following reference page, which covers the different approaches.
At work we have quite a large code base and I am really, really trying to get Semantic to just work. Yesterday it seemed to have parsed the file I was working on as well as the non-system includes: Great. I could create an instance of a class which is defined in another include file and after construction I could browse through all the functions etc with a key binded to semantic-ia-complete-symbol-meu.
Firstly, I am using:
Emacs 24.3.1 with
CEDET bzr version: rev_8678.tar.gz and, all of this is running on
Windows 7 (unfortunately).
MinGW and MSYS installed
Microsoft Visual Studio 10
In my .emacs (related to CEDET stuff):
;; MODE: CEDET
(load-file "~/.emacs.d/cedet/cedet-devel-load.el") ;; This is the latest dev' version ~~ 26th Sept 2014
;; Add further minor-modes to be enabled by semantic-mode.
;; See doc-string of `semantic-default-submodes' for other things
;; you can use here.
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode t)
(add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode t)
(semantic-mode 1)
(global-ede-mode 1)
;(global-semantic-decoration-mode)
;(setq semanticdb-default-save-directory "~/.emacs.d/.semanticdb/")
;(add-to-list 'magic-fallback-mode-alist '("^// " . c++-mode))
;(add-to-list 'magic-fallback-mode-alist '("^#include" . c++-mode))
;(semantic-add-system-include "c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include" 'c++-mode)
;(semantic-add-system-include "/usr/include/c++/3.4.4")
Therefore, my default semantic database location is ~/.emacs.d/semanticdb
I come in today and find that when I load the same file up I keep on getting three errors (both of which I have searched for but nothing matches my issue):
Parsing main.cpp (LL)...
Idle Parse Error: "#<buffer main.cpp> - End of buffer"
And
Save Error: nil: c:/Users/[MY_USER]/.emacs.d/semanticdb/!drive_[STUFF_HERE]!semantic.cache
And
Idle Service Error semantic-idle-summary-idle-function: "#<buffer main.cpp> - End of buffer"
As I said, this was working yesterday, so why not today? (PS: Btw, this only happens with main.cpp - when I search for definitions of functions using xcscope and open the definition up the file is parsed correctly with CEDET and local includes are parsed and I can symbol-lookup, it seems to just be main.cpp for some reason.)
PS: I have just read a similar problem that someone has with MATLAB. The solution was to either create the directory stated in the matlab-include path, or change the list in the path. But, this does not make sense to my situation because this was working yesterday and I have not touched CEDET since yesterday at all.
semantic-c-dependency-system-include-path is a variable defined in `c.el'.
Its value is ("/usr/include")
semantic-dependency-include-path is a variable defined in `dep.el'.
Its value is nil
Local in buffer main.cpp; global value is the same.
Both of these are the same as yesterday.
PS: Also, when semantic-mode is enabled I am no longer to use (imenu-add-to-menubar) - I only get the option to rescan everything. However, when I do not have semantic-mode enabled then this works fine. I did not know that semantic messed with imenu unless you told it to?
It is all a little annoying because I really like the potential of CEDET/Semantic and appreciate the work that has been put into it. Emacs is already powerful, but with a fully working CEDET its power tends to over 9000!
I believe the developers involved with CEDET should run tests on a Windows machine so that any bugs can be found with Windows issues. I know the OS is horrible but some developers are forced to use it in the workplace. I have never found an issue with CEDET so far on my Linux machines because things are in standard places! But, this is about Windows.
PS: If it is any help a very simple project works fine with this set up and CEDET. I have, in a completely different place:
emacs_test_semantic> ls -l
total 103
-rw-r--r-- 1 [USER] Administrators 43 Oct 2 17:28 Makefile
-rw-r--r-- 1 [USER] Administrators 158 Oct 8 12:04 main.cpp
-rw-r--r-- 1 [USER] Administrators 247 Oct 1 12:51 myClass.cpp
-rw-r--r-- 1 [USER] Administrators 159 Oct 1 12:51 myClass.hpp
-rwxr-xr-x 1 [USER] Administrators 99862 Oct 2 17:28 output.exe
And, in the main:
#include <list>
#include "myClass.hpp"
using namespace std;
int main() {
MC CLASS( 3, 5 );
list<MC> myList;
myList.
return 0;
}
So, I am able to complete symbols of the MC class, however, not the STL list. BUT, this is topic is not about being able to complete STL functions/templates because there are many questions on this.
This small project, even though with (global-semantic-decoration-mode) enabled and a RED over #include <vector> does not give the same three errors described above. Also, imenu works!
===
In summary, I am somewhat confused as to the inconsistency, here. The fact that in the large code base things worked yesterday, but now I have these three errors that I didn't get before!
===
PS: Just after I wrote this I load up that same file and this time global-decoration-mode shows that the local includes are actually now understood! Even though I have changed nothing. So now it seems to work again - but it is this inconsistency which is not understandable.
Well, it works for one branch and not for another. Interestingly, in the branch that gives me the three errors (indicated above) I have a DB file (and imenu does not work, and nor is decoration-mode visable:
-rw-r--r-- 1 [USER] Administrators 449 Oct 8 13:42 !drive_d![SOME_STUFF]!semantic.cache
Compared to the one that works which is (where, global-decoration-mode is visible and imenu works):
-rw-r--r-- 1 [USER] Administrators 555184 Oct 8 13:51 !drive_d![SOME_STUFF]!semantic.cache
You can see the big difference in size. And these two branches only differ in a completely different location in the code base. So, just some extra information.
===
As a user of CEDET/semantic (albeit, not a very good one) I would really like to know a way to manually FORCE the parsing of all files in a given list that is wrote to the DB rather than relying on semantic to do it. This has been requested before and people have created some hack lisp, but with CEDET ever changing from 1.1 the code does not work.
===
PS: Latest edit: Out of no where the errors have gone away, the only thing I can remember doing is saving the buffer. You can tell when the errors have gone away because the global-decaration's start to show - i.e. the underlines and highlighted include files. Is this because I saved the buffer? I am unsure. I cannot recall if I was saving it before. Also, the file save of the DB has increased and the last modification of the DB file was a few minutes ago from this post:
What was before:
-rw-r--r-- 1 [USER] Administrators 449 Oct 8 13:42 !drive_d![SOME_STUFF]!semantic.cache
Is now:
-rw-r--r-- 1 [USER] Administrators 158327 Oct 8 15:38 !drive_d![SOME_STUFF]!semantic.cache
Having just messed about at work a lot of the glitches that I originally found are starting to make sense and are appearing to be just my lack of understanding of the product. There is no problem parsing system includes (such as STL) or local includes anymore on Windows and this is mainly down the the brilliant feature of: global-semantic-decoration-mode. It makes it clear if a source file has been parsed or not, etc etc. So now, I use this in my .emacs.
The problem of inconsistency (which I have found is not inconsistency, see below) - I have found - arises when the parser comes across a line of code like this:
#if defined(X)
//hundreds of lines of code
#endif /* define(X) */
I can half understand it. Unless X has been defined then don't bother parsing. But, I still want CEDET/Semantic to work on all of the code. I still might want to use completion if I am working in a function that exists in an area non-existent because of something undefined.
I say, naively, that semantic/cedet should parse code regardless of whether something is defined or not. However, perhaps this was a premeditated feature?
Thanks.
I have a class that meets regularly on Mondays/Wednesdays from 12:00-12:50 and on Thursdays from 16:00-16:50. I'd like to keep all the notes together, because it's all for the same class, but I don't know how I would set up this recurring event.
There is an easy-enough way to define arbitrary date ranges, but nothing I can see for time ranges that would also show up correctly in the agenda. They're also in different rooms, so if it's possible I'd like to add something denoting the room number. If it were just dates (at the same time as well), I would go ahead and just
(and (org-class 2013 1 21 2013 5 9 1) (org-class 2013 1 21 2013 5 9 3))
and it would be fine. Is there a(n org-mode) function to describe times? Is there a way to add notes (like the room number)? I'm not quite aware of how this whole section of org-mode works (although my guess would be that if the sexp evaluates to non-nil, then the event is active).
So, in summary, I'd like a way to be able to assign arbitrary collections of date-time-range objects to org-mode events, ideally with the notes I was talking about.
EDIT
As a secondary (but obviously related) question, what's the sexp way of specifying time?
You can use multiple time-stamps within the same entry.
For example:
C-c.mon 12:00-12:50RET will produce <2013-01-28 Mon 12:00-12:50>. You can then edit it to add a repeater +1w. The final time-stamp looks like <2013-01-28 Mon 12:00-12:50 +1w>.
I don't know how you can manage the class room though.
Wouldn't creating subtrees for the two rooms and then a third subtree for the notes themselves?
For example (see Org-FAQ for details on putting time in the same line. I think adding the time within the <> will add it to the time, but not entirely sure, otherwise add it afterwards and it should still include it within the information.
* Math Class
:PROPERTIES:
:CATEGORY: Math Class
:END:
** Room #1
<%%(and (org-class 2013 1 21 2013 5 9 1) (org-class 2013 1 21 2013 5 9 3)) 12:00-- 12:50>
** Room #2
<%%(org-class 2013 1 21 2013 5 9 4) 16:00--16:50>
** Notes
I would like to use agenda to keep track of my classes, assuming i have a com 355 class every week from march to june,
<2010-03-23 Tue 10:40-12:10 +1w>
this works but it schedules it indefinitely if i use,
<2010-03-23 Tue 10:40-12:10 +1w>-<2010-06-23>
it gets scheduled for everyday from march to june, how can i schedule this once a week for a period of time?
I had a similar problem and found usefull the answer to "How can I create more complex appointments in my org-files?" in the FAQ at http://orgmode.org/worg/org-faq.html#Appointments/Diary You can even add exceptions for holidays. I was not able to make work the time though: when you add it the formula stops working :(
1) My example: Courses on Tuesdays and Thursdays falling in [2011-03-07 Mon]--[2011-06-25 Sat] minus [2011-05-15 Sun]--[2011-05-20 Fri] (a week of holiday):
** TEST Tuesday and Thursday in [2011-03-07 Mon]-[2011-06-20 Mon] minus holidays [2011-05-15 Sun]-[2011-05-22 Sun]
<%%(and (diary-block 3 7 2011 6 20 2011)(or (= 2 (calendar-day-of-week date) (= 4 (calendar-day-of-week date))))(not (diary-block 5 15 2011 5 22 2011)))>
If you decompose the boolean function, you get the following, which is self explanatory:
<%%(and (diary-block 3 7 2011 6 20 2011)
(or (= 2 (calendar-day-of-week date) (= 4 (calendar-day-of-week date))))
(not (diary-block 5 15 2011 5 22 2011))
)>
2) My suggestion for your case: a class every Tuesday every week from March to June (I took the liberty to fix the year to 2011):
<%%(and (= 2 (calendar-day-of-week date)) (diary-block 3 23 2011 6 23 2011)))>
You might want to have a look to the newly added section "How can I schedule a weekly class that lasts for a limited period of time?", about the function "org-diary-class", but it still seems to have problem with scheduling hours :(
Hope it helps,
There might not be a way to do that directly, but Org-mode allows you to specify times using the diary sexp style. (http://orgmode.org/org.html#Timestamps)
If you look at some of the examples in the manual for the diary functions (http://www.gnu.org/software/emacs/manual/html_node/emacs/Sexp-Diary-Entries.html#Sexp-Diary-Entries) you'll see that you can provide arbitrary code to define the occurrences of the event.
There is no way to do what you want --- ranges don't work for this (I asked on the org-mode list).
You can clone the appointment, setting the clones one week apart. This will give you one instance of the item for every day in the period. This might be cumbersome, or it might be just what you want.
You can use the diary to do this, there's an explanation here if you follow the instructions (make sure you have a ~/diary file) then it will pick it up and add it to your agenda. You may need to alter your date format depending on your settings.
Something like this should do the trick, and it should schedule hours
%%(org-diary-class 2011 5 31 2011 10 13 2) 5:00pm-6:30pm German Class
%%(org-diary-class 2011 5 31 2011 10 13 4) 6:45pm-8:15pm German Class
Where the numbers represent
Start Y M D Finish Y M D DayOfWeek (Sun = 0, Mon = 1 ...)
This works for me already many years:
* Modeling of curves and surfaces II 13:10-14:40
<%%(org-class 2019 2 18 2019 5 17 4 13)>