BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
acordes
Rhodochrosite | Level 12

It takes a long time to score and once finished in the log a note states that only one thread was used. 

 

proc cas;
      loadactionset "DS2";
      runmodel /
      modelname="Forest_recovery_maig2_tarde",
      modeltable={caslib="DNA", name="sas_model_table" },
      table = {caslib="public", name="recovery_candidates2" },
      casout={caslib="busidev", name="ac_scored"};
run;
1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

Yes, you should have put it in 'SAS Data Science Board' indeed.

 

Is it possible for you to open a track at Technical Support in your country?

Technical Support (TS) knows about this problem.

I refer you to TS because the root cause and the work-around (there is no real 'solution') is a very long explanation that they can probably do better than me.

 

BR,

Koen

View solution in original post

10 REPLIES 10
Rick_SAS
SAS Super FREQ

The documentation for the DS2.runModel action 

SAS Help Center: DS2 Details

includes this caution: "It is recommended that the DS2 code that is run with the runModel action include a THREAD program. This allows the DS2 code to run as a DS2 parallel program and therefore leverage the full set of worker nodes on the CAS server."

 

You can see the DS2 documentation for more information about how to use the THREAD/ENDTRHEAD block for parallel processing: SAS Help Center: THREAD Statement

acordes
Rhodochrosite | Level 12

I don't understand what I'm doing... I copy/paste from the link you shared. 

Fact is that I don't succeed in getting the table PUBLIC.RECOVERY_CANDIDATES2 scored. 

The code without thread works but is very slow.

The thread option is resolved correctly but I don't know what the runmodel statement should look like.

 

here is my failed intent. 

proc cas;
  loadactionset "modelPublishing";
  publishModel  /                                       /*5*/
  modelName="Forest_recovery_maig2_tarde",
  modelTable={caslib="DNA", name="sas_model_table" },
  program= "
     thread cars_thd / overwrite=yes;
       method run();
         set PUBLIC.RECOVERY_CANDIDATES2;
/*          if (msrp > 100000) then do; */
/*            put make= model= msrp=; */
/*            output; */
/*          end; */
       end;
     endthread;
     data busidev.cars_luxury /overwrite=yes;
       dcl thread cars_thd t;
       method run();
         set from t threads=8;
       end;
     enddata;";
  run;

      loadactionset "DS2";
      runmodel /
      modelname="Forest_recovery_maig2_tarde",
      modeltable={caslib="DNA", name="sas_model_table" }
/*       table = {caslib="public", name="recovery_candidates2" }, */
      table = {caslib="busidev", name="cars_luxury" },
      casout={caslib="busidev", name="ac_scored2"};
run;

 

 

acordes
Rhodochrosite | Level 12

Ok, I'm starting to understand a little bit. 

I overwrite my model Forest_recovery_maig2_tarde with the publishing option and then nothing happens because I do not define a 'model' in the program statement...

So I need to copy/paste the method run() block from the model studio where I trained the model, right?

Or how do I run the EXISTING model in multiple threads without the modelpublishing block? 

acordes
Rhodochrosite | Level 12

@Rick_SAS I can use alternatively the proc astore and it works. 

But I want to use the ds2 actionset because I want to score within the IMLactionset calling 'submit'. 

It works, but it's slow if it's not multithread. 

Rick_SAS
SAS Super FREQ

I do not have any experience doing what you are attempting to do. However, when I want to write a complicated program, it always goes better when I slowly study and implement each individual piece. Start with a regular DS2 program that has a THREAD statement. Get it working in multiple threads. Move on to creating and publishing a model, and so forth.

 

Good luck!

acordes
Rhodochrosite | Level 12

@BrunoMueller can you help me out?

acordes
Rhodochrosite | Level 12

I think that I'm close to the solution. 

I run the runmodel.action which executes but slowly. 

I copy/paste the log information to the thread program. 

It creates the desired table including the prediction variables but quits before writing any observations to it. 

The error message is. 

ERROR: Line 14: Error reported by DS2 package d2score:
ERROR: Line 14: Store identified by the key 6031C39C5FDB19CC9D86D42C7A7E7FE76987AEB2 is not in memory.

 

When using the runmodel action the store is found and executes correctly. 

 

cas mysession sessopts=(caslib="casuser");
proc cas; 
   session mysession; 
   source myprogram1;
      thread datagen / overwrite=yes;              
          dcl package score _BAY103MSXS55GR1KJPG052A1W();
          dcl double "P_target_recovery1" having label n'Predicted: target_recovery=1';
          dcl double "P_target_recovery0" having label n'Predicted: target_recovery=0';
          dcl nchar(32) "I_target_recovery" having label n'Into: target_recovery';
          dcl nchar(4) "_WARN_" having label n'Warnings';
          dcl double EM_EVENTPROBABILITY;
          dcl nchar(8) EM_CLASSIFICATION;
          dcl double EM_PROBABILITY;
          varlist allvars [_all_];
                    
          method init();
          _BAY103MSXS55GR1KJPG052A1W.setvars(allvars);
          _BAY103MSXS55GR1KJPG052A1W.setkey(n'6031C39C5FDB19CC9D86D42C7A7E7FE76987AEB2');
          end;
                   method post_BAY103MSXS55GR1KJPG052A1W();
          dcl double _P_;
                       if "P_TARGET_RECOVERY0" = . then "P_TARGET_RECOVERY0" = 0.6131360717;
          if "P_TARGET_RECOVERY1" = . then "P_TARGET_RECOVERY1" = 0.3868639283;
          if MISSING("I_TARGET_RECOVERY") then do ;
          _P_ = 0.0;
          if "P_TARGET_RECOVERY1" > _P_ then do ;
          _P_ = "P_TARGET_RECOVERY1";
          "I_TARGET_RECOVERY" = '1';
          end;
          if "P_TARGET_RECOVERY0" > _P_ then do ;
          _P_ = "P_TARGET_RECOVERY0";
          "I_TARGET_RECOVERY" = '0';
          end;
          end;
          EM_EVENTPROBABILITY = "P_TARGET_RECOVERY1";
          EM_CLASSIFICATION = "I_TARGET_RECOVERY";
          EM_PROBABILITY = MAX("P_TARGET_RECOVERY1", "P_TARGET_RECOVERY0");
                   end;
                 
          method run();
          set "CASUSER(DKXENLO)"."bigdata";
          _BAY103MSXS55GR1KJPG052A1W.scoreRecord();
          post_BAY103MSXS55GR1KJPG052A1W();
end;
         method term();
end;


      endthread;

/* Run the DATA program on all CAS workers. */
   data bigdata_sc / overwrite=yes;                          
         dcl thread datagen dg;                              
         method run();                                       
            set from dg threads=8;                       /*5*/
         end;
      enddata;
   endsource;

   ds2.runDS2 program=myprogram1; 
   run;
acordes
Rhodochrosite | Level 12

Hi Koen @sbxkoenk 

Perhaps you know the solution. I should have placed this post in data science I guess.

sbxkoenk
SAS Super FREQ

Yes, you should have put it in 'SAS Data Science Board' indeed.

 

Is it possible for you to open a track at Technical Support in your country?

Technical Support (TS) knows about this problem.

I refer you to TS because the root cause and the work-around (there is no real 'solution') is a very long explanation that they can probably do better than me.

 

BR,

Koen

BrunoMueller
SAS Super FREQ
I am sorry but I can not help with this.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 893 views
  • 2 likes
  • 4 in conversation