Error running OLGModel1.m without GPU

Hello,

I am trying to run the basic OLG models from the IntroToOLG files without access to a GPU (I know that this is not recommended, but I have no other option at the moment). I hoped that this would work at longer running times, but I receive the error message pasted below. For context, the Life Cycle models worked with my set-up. I tried to make sense of this but could not - any help would be appreciated!

Index in position 3 exceeds array bounds. Index must not exceed 1.

Error in ValueFnIter_Case1_FHorz_noz_Par1_raw (line 95)
VKronNext_j=V(:,:,jj+1);

Error in ValueFnIter_Case1_FHorz (line 560)
[VKron, PolicyKron]=ValueFnIter_Case1_FHorz_noz_Par1_raw(n_d,n_a, N_j, d_grid, a_grid, ReturnFn, Parameters, DiscountFactorParamNames, ReturnFnParamNames, vfoptions);

Error in OLGModel4 (line 133)
[V, Policy]=ValueFnIter_Case1_FHorz(n_d,n_a,n_z,N_j, d_grid, a_grid, z_grid, pi_z, ReturnFn, Params, DiscountFactorParamNames, [], vfoptions);

I am on holiday at the moment so cannot actually look at what the issue is, but based on the error message it is probably actually a mistake in “ValueFnIter_Case1_FHorz_noz_Par1_raw.m” (should probably just say …=V(:,j+1); ). I will fix it when I get back (not until mid-July I’m afraid). [Because I never really use the codes without GPU they are not always the cleanest.]

If you want to run some things without GPU it might be better to start from the Huggett (1996) example (which is an OLG model), just because this is specifically something that is known to work on cpu.

Side comment: the reason for requiring a GPU is not that these models cannot be solve without, just that the main algorithms used by VFI Toolkit are very much built around what GPUs are good at but which is a terrible approach for CPUs.

1 Like

Thank you for your prompt response - and you are totally right!

To solve the issue I followed your suggestion and changed ValueFnIter_Case1_FHorz_noz_Par1_raw.m line 95:

old:
VKronNext_j=V(:,:,jj+1);

new:
VKronNext_j=V(:,jj+1);

Even though it’s slow to solve the OLG models it is very helpful to be able to do so while I wait for access to a GPU!

Cool. I have applied the fix directly to github since you confirm it works :smiley: